mod-setenv.t 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env perl
  2. BEGIN {
  3. # add current source dir to the include-path
  4. # we need this for make distcheck
  5. (my $srcdir = $0) =~ s,/[^/]+$,/,;
  6. unshift @INC, $srcdir;
  7. }
  8. use strict;
  9. use IO::Socket;
  10. use Test::More tests => 6;
  11. use LightyTest;
  12. my $tf = LightyTest->new();
  13. my $t;
  14. ok($tf->start_proc == 0, "Starting lighttpd") or die();
  15. $t->{REQUEST} = ( <<EOF
  16. GET /get-header.pl?TRAC_ENV HTTP/1.0
  17. Host: www.example.org
  18. EOF
  19. );
  20. $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'tracenv' } ];
  21. ok($tf->handle_http($t) == 0, 'query first setenv');
  22. $t->{REQUEST} = ( <<EOF
  23. GET /get-header.pl?SETENV HTTP/1.0
  24. Host: www.example.org
  25. EOF
  26. );
  27. $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'setenv' } ];
  28. ok($tf->handle_http($t) == 0, 'query second setenv');
  29. $t->{REQUEST} = ( <<EOF
  30. GET /get-header.pl?HTTP_FOO HTTP/1.0
  31. Host: www.example.org
  32. EOF
  33. );
  34. $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'foo' } ];
  35. ok($tf->handle_http($t) == 0, 'query add-request-header');
  36. $t->{REQUEST} = ( <<EOF
  37. GET /index.html HTTP/1.0
  38. Host: www.example.org
  39. EOF
  40. );
  41. $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'BAR' => 'foo' } ];
  42. ok($tf->handle_http($t) == 0, 'query add-response-header');
  43. ok($tf->stop_proc == 0, "Stopping lighttpd");