comparison scgi.t @ 167:b8fdbc918280

Tests: add scgi headers_param test.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 18 Aug 2011 01:59:57 +0400
parents c0ae29632905
children a7cc4371f4ad
comparison
equal deleted inserted replaced
166:c0ae29632905 167:b8fdbc918280
22 select STDOUT; $| = 1; 22 select STDOUT; $| = 1;
23 23
24 eval { require SCGI; }; 24 eval { require SCGI; };
25 plan(skip_all => 'SCGI not installed') if $@; 25 plan(skip_all => 'SCGI not installed') if $@;
26 26
27 my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(4) 27 my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(5)
28 ->write_file_expand('nginx.conf', <<'EOF'); 28 ->write_file_expand('nginx.conf', <<'EOF');
29 29
30 %%TEST_GLOBALS%% 30 %%TEST_GLOBALS%%
31 31
32 daemon off; 32 daemon off;
43 43
44 location / { 44 location / {
45 scgi_pass 127.0.0.1:8081; 45 scgi_pass 127.0.0.1:8081;
46 scgi_param SCGI 1; 46 scgi_param SCGI 1;
47 scgi_param REQUEST_URI $request_uri; 47 scgi_param REQUEST_URI $request_uri;
48 scgi_param HTTP_X_BLAH "blah";
48 } 49 }
49 } 50 }
50 } 51 }
51 52
52 EOF 53 EOF
59 like(http_get('/'), qr/SEE-THIS/, 'scgi request'); 60 like(http_get('/'), qr/SEE-THIS/, 'scgi request');
60 like(http_get('/redir'), qr/302/, 'scgi redirect'); 61 like(http_get('/redir'), qr/302/, 'scgi redirect');
61 like(http_get('/'), qr/^3$/m, 'scgi third request'); 62 like(http_get('/'), qr/^3$/m, 'scgi third request');
62 63
63 unlike(http_head('/'), qr/SEE-THIS/, 'no data in HEAD'); 64 unlike(http_head('/'), qr/SEE-THIS/, 'no data in HEAD');
65
66 SKIP: {
67 skip 'unsafe', 1 unless $ENV{TEST_NGINX_UNSAFE};
68 local $TODO = 'not yet';
69
70 like(http_get_headers('/headers'), qr/SEE-THIS/,
71 'scgi request with many ignored headers');
72
73 }
74
75 ###############################################################################
76
77 sub http_get_headers {
78 my ($url, %extra) = @_;
79 return http(<<EOF, %extra);
80 GET $url HTTP/1.0
81 Host: localhost
82 X-Blah: ignored header
83 X-Blah: ignored header
84 X-Blah: ignored header
85 X-Blah: ignored header
86 X-Blah: ignored header
87 X-Blah: ignored header
88 X-Blah: ignored header
89 X-Blah: ignored header
90 X-Blah: ignored header
91 X-Blah: ignored header
92 X-Blah: ignored header
93 X-Blah: ignored header
94 X-Blah: ignored header
95 X-Blah: ignored header
96 X-Blah: ignored header
97 X-Blah: ignored header
98 X-Blah: ignored header
99 X-Blah: ignored header
100 X-Blah: ignored header
101
102 EOF
103 }
64 104
65 ############################################################################### 105 ###############################################################################
66 106
67 sub scgi_daemon { 107 sub scgi_daemon {
68 my $server = IO::Socket::INET->new( 108 my $server = IO::Socket::INET->new(