Mercurial > hg > nginx-tests
comparison scgi.t @ 952:e9064d691790
Tests: converted tests to run in parallel.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 21 Jun 2016 16:39:13 +0300 |
parents | eca9b1d19021 |
children | d4a0232425ee |
comparison
equal
deleted
inserted
replaced
951:9361c7eddfc1 | 952:e9064d691790 |
---|---|
36 | 36 |
37 http { | 37 http { |
38 %%TEST_GLOBALS_HTTP%% | 38 %%TEST_GLOBALS_HTTP%% |
39 | 39 |
40 upstream u { | 40 upstream u { |
41 server 127.0.0.1:8081; | 41 server 127.0.0.1:%%PORT_1%%; |
42 } | 42 } |
43 | 43 |
44 server { | 44 server { |
45 listen 127.0.0.1:8080; | 45 listen 127.0.0.1:%%PORT_0%%; |
46 server_name localhost; | 46 server_name localhost; |
47 | 47 |
48 location / { | 48 location / { |
49 scgi_pass 127.0.0.1:8081; | 49 scgi_pass 127.0.0.1:%%PORT_1%%; |
50 scgi_param SCGI 1; | 50 scgi_param SCGI 1; |
51 scgi_param REQUEST_URI $request_uri; | 51 scgi_param REQUEST_URI $request_uri; |
52 scgi_param HTTP_X_BLAH "blah"; | 52 scgi_param HTTP_X_BLAH "blah"; |
53 } | 53 } |
54 | 54 |
75 unlike(http_head('/'), qr/SEE-THIS/, 'no data in HEAD'); | 75 unlike(http_head('/'), qr/SEE-THIS/, 'no data in HEAD'); |
76 | 76 |
77 like(http_get_headers('/headers'), qr/SEE-THIS/, | 77 like(http_get_headers('/headers'), qr/SEE-THIS/, |
78 'scgi request with many ignored headers'); | 78 'scgi request with many ignored headers'); |
79 | 79 |
80 like(http_get('/var?b=127.0.0.1:8081'), qr/SEE-THIS/, 'scgi with variables'); | 80 like(http_get('/var?b=127.0.0.1:' . port(1)), qr/SEE-THIS/, |
81 'scgi with variables'); | |
81 like(http_get('/var?b=u'), qr/SEE-THIS/, 'scgi with variables to upstream'); | 82 like(http_get('/var?b=u'), qr/SEE-THIS/, 'scgi with variables to upstream'); |
82 | 83 |
83 ############################################################################### | 84 ############################################################################### |
84 | 85 |
85 sub http_get_headers { | 86 sub http_get_headers { |
113 ############################################################################### | 114 ############################################################################### |
114 | 115 |
115 sub scgi_daemon { | 116 sub scgi_daemon { |
116 my $server = IO::Socket::INET->new( | 117 my $server = IO::Socket::INET->new( |
117 Proto => 'tcp', | 118 Proto => 'tcp', |
118 LocalHost => '127.0.0.1:8081', | 119 LocalHost => '127.0.0.1:' . port(1), |
119 Listen => 5, | 120 Listen => 5, |
120 Reuse => 1 | 121 Reuse => 1 |
121 ) | 122 ) |
122 or die "Can't create listening socket: $!\n"; | 123 or die "Can't create listening socket: $!\n"; |
123 | 124 |
127 while (my $request = $scgi->accept()) { | 128 while (my $request = $scgi->accept()) { |
128 $count++; | 129 $count++; |
129 $request->read_env(); | 130 $request->read_env(); |
130 | 131 |
131 $request->connection()->print(<<EOF); | 132 $request->connection()->print(<<EOF); |
132 Location: http://127.0.0.1:8080/redirect | 133 Location: http://localhost/redirect |
133 Content-Type: text/html | 134 Content-Type: text/html |
134 | 135 |
135 SEE-THIS | 136 SEE-THIS |
136 $count | 137 $count |
137 EOF | 138 EOF |