comparison http_header_buffers.t @ 1143:b9d9c962255f

Tests: more large_client_header_buffers tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 01 Mar 2017 21:18:28 +0300
parents 56d5efd16af6
children 66c7dee0431c
comparison
equal deleted inserted replaced
1142:baeebac35a2e 1143:b9d9c962255f
22 ############################################################################### 22 ###############################################################################
23 23
24 select STDERR; $| = 1; 24 select STDERR; $| = 1;
25 select STDOUT; $| = 1; 25 select STDOUT; $| = 1;
26 26
27 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(2) 27 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(8)
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;
64 64
65 large_client_header_buffers 1 256; 65 large_client_header_buffers 1 256;
66 66
67 return 204; 67 return 204;
68 } 68 }
69
70 server {
71 listen 127.0.0.1:8080;
72 server_name foo;
73
74 large_client_header_buffers 5 256;
75
76 add_header X-URI $uri;
77 add_header X-Foo $http_x_foo;
78 return 204;
79 }
69 } 80 }
70 81
71 EOF 82 EOF
72 83
73 $t->run(); 84 $t->run();
87 "Host: ten" . CRLF . 98 "Host: ten" . CRLF .
88 "X-Foo: " . ("1234567890" x 20) . CRLF . 99 "X-Foo: " . ("1234567890" x 20) . CRLF .
89 "X-Foo: " . ("1234567890" x 20) . CRLF . 100 "X-Foo: " . ("1234567890" x 20) . CRLF .
90 "X-Foo: " . ("1234567890" x 20) . CRLF . 101 "X-Foo: " . ("1234567890" x 20) . CRLF .
91 "X-Foo: " . ("1234567890" x 20) . CRLF . 102 "X-Foo: " . ("1234567890" x 20) . CRLF .
92 "X-Foo: " . ("1234567890" x 20) . CRLF . CRLF 103 "X-Foo: " . ("1234567890" x 20) . CRLF .
104 CRLF
93 ), qr/204|400/, 'additional buffers in virtual server'); 105 ), qr/204|400/, 'additional buffers in virtual server');
94 106
95 # for pipelined requests large header buffers are saved to hc->free; 107 # for pipelined requests large header buffers are saved to hc->free;
96 # it sized for number of buffers in the current virtual server, but 108 # it sized for number of buffers in the current virtual server, but
97 # saves previously allocated buffers, and there may be more buffers if 109 # saves previously allocated buffers, and there may be more buffers if
102 "X-Foo: " . ("1234567890" x 20) . CRLF . 114 "X-Foo: " . ("1234567890" x 20) . CRLF .
103 "X-Foo: " . ("1234567890" x 20) . CRLF . 115 "X-Foo: " . ("1234567890" x 20) . CRLF .
104 "X-Foo: " . ("1234567890" x 20) . CRLF . 116 "X-Foo: " . ("1234567890" x 20) . CRLF .
105 "X-Foo: " . ("1234567890" x 20) . CRLF . 117 "X-Foo: " . ("1234567890" x 20) . CRLF .
106 "X-Foo: " . ("1234567890" x 20) . CRLF . 118 "X-Foo: " . ("1234567890" x 20) . CRLF .
107 "Host: one" . CRLF . CRLF . 119 "Host: one" . CRLF .
120 CRLF .
108 "GET / HTTP/1.1" . CRLF . 121 "GET / HTTP/1.1" . CRLF .
109 "Host: one" . CRLF . 122 "Host: one" . CRLF .
110 "Connection: close" . CRLF . CRLF 123 "Connection: close" . CRLF .
124 CRLF
111 ), qr/204/, 'pipelined with too many buffers'); 125 ), qr/204/, 'pipelined with too many buffers');
112 126
113 } 127 }
114 128
129 # check if long header and long request lines are correctly returned
130 # when nginx allocates a long header buffer
131
132 like(http(
133 "GET / HTTP/1.0" . CRLF .
134 "Host: foo" . CRLF .
135 "X-Foo: foo" . ("1234567890" x 20) . "bar" . CRLF .
136 CRLF
137 ), qr/X-Foo: foo(1234567890){20}bar/, 'long header');
138
139 like(http(
140 "GET /foo" . ("1234567890" x 20) . "bar HTTP/1.0" . CRLF .
141 "Host: foo" . CRLF .
142 CRLF
143 ), qr!X-URI: /foo(1234567890){20}bar!, 'long request line');
144
145 # the same as the above, but with pipelining, so there is a buffer
146 # allocated in the previous request
147
148 like(http(
149 "GET / HTTP/1.1" . CRLF .
150 "Host: foo" . CRLF .
151 "X-Foo: " . ("1234567890" x 20) . CRLF .
152 CRLF .
153 "GET / HTTP/1.1" . CRLF .
154 "Host: foo" . CRLF .
155 "Connection: close" . CRLF .
156 "X-Foo: foo" . ("1234567890" x 20) . "bar" . CRLF .
157 CRLF
158 ), qr/X-Foo: foo(1234567890){20}bar/, 'long header after pipelining');
159
160 like(http(
161 "GET / HTTP/1.1" . CRLF .
162 "Host: foo" . CRLF .
163 "X-Foo: " . ("1234567890" x 20) . CRLF .
164 CRLF .
165 "GET /foo" . ("1234567890" x 20) . "bar HTTP/1.1" . CRLF .
166 "Host: foo" . CRLF .
167 "Connection: close" . CRLF .
168 CRLF
169 ), qr!X-URI: /foo(1234567890){20}bar!, 'long request line after pipelining');
170
171 # the same as the above, but with keepalive; this ensures that previously
172 # allocated buffers are properly cleaned up when we set keepalive handler
173
174 like(http(
175 "GET / HTTP/1.1" . CRLF .
176 "Host: foo" . CRLF .
177 "X-Foo: " . ("1234567890" x 20) . CRLF .
178 CRLF,
179 sleep => 0.1, body =>
180 "GET / HTTP/1.1" . CRLF .
181 "Host: foo" . CRLF .
182 "Connection: close" . CRLF .
183 "X-Foo: foo" . ("1234567890" x 20) . "bar" . CRLF .
184 CRLF
185 ), qr/X-Foo: foo(1234567890){20}bar/, 'long header after keepalive');
186
187 like(http(
188 "GET / HTTP/1.1" . CRLF .
189 "Host: foo" . CRLF .
190 "X-Foo: " . ("1234567890" x 20) . CRLF .
191 CRLF,
192 sleep => 0.1, body =>
193 "GET /foo" . ("1234567890" x 20) . "bar HTTP/1.1" . CRLF .
194 "Host: foo" . CRLF .
195 "Connection: close" . CRLF .
196 CRLF
197 ), qr!X-URI: /foo(1234567890){20}bar!, 'long request line after keepalive');
198
115 ############################################################################### 199 ###############################################################################