comparison h2_proxy_request_buffering.t @ 983:daf3fb13a80d

Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 06 Jul 2016 15:57:26 +0300
parents 882267679006
children d0523391deb9
comparison
equal deleted inserted replaced
982:325db3d62466 983:daf3fb13a80d
39 http { 39 http {
40 %%TEST_GLOBALS_HTTP%% 40 %%TEST_GLOBALS_HTTP%%
41 41
42 server { 42 server {
43 listen 127.0.0.1:8080 http2; 43 listen 127.0.0.1:8080 http2;
44 listen 127.0.0.1:8082;
44 server_name localhost; 45 server_name localhost;
45 46
46 location / { 47 location / {
47 proxy_request_buffering off; 48 proxy_request_buffering off;
48 proxy_pass http://127.0.0.1:8081/; 49 proxy_pass http://127.0.0.1:8081/;
52 proxy_request_buffering off; 53 proxy_request_buffering off;
53 proxy_http_version 1.1; 54 proxy_http_version 1.1;
54 proxy_pass http://127.0.0.1:8081/; 55 proxy_pass http://127.0.0.1:8081/;
55 client_body_buffer_size 1k; 56 client_body_buffer_size 1k;
56 } 57 }
58 location /abort {
59 proxy_request_buffering off;
60 proxy_http_version 1.1;
61 proxy_pass http://127.0.0.1:8082/;
62 }
57 } 63 }
58 } 64 }
59 65
60 EOF 66 EOF
61 67
63 69
64 my $f = get_body('/chunked'); 70 my $f = get_body('/chunked');
65 plan(skip_all => 'no unbuffered request body') unless $f; 71 plan(skip_all => 'no unbuffered request body') unless $f;
66 $f->{http_end}(); 72 $f->{http_end}();
67 73
68 $t->plan(48); 74 $t->plan(49);
69 75
70 ############################################################################### 76 ###############################################################################
71 77
72 # unbuffered request body 78 # unbuffered request body
73 79
157 ok($f->{headers}, 'chunked split'); 163 ok($f->{headers}, 'chunked split');
158 is($f->{upload}('0123456789', split => [ 14 ]), 164 is($f->{upload}('0123456789', split => [ 14 ]),
159 '5' . CRLF . '01234' . CRLF . '5' . CRLF . '56789' . CRLF . 165 '5' . CRLF . '01234' . CRLF . '5' . CRLF . '56789' . CRLF .
160 '0' . CRLF . CRLF, 'chunked split'); 166 '0' . CRLF . CRLF, 'chunked split');
161 is($f->{http_end}(), 200, 'chunked split - response'); 167 is($f->{http_end}(), 200, 'chunked split - response');
168
169 # unbuffered request body, chunked transfer-encoding
170 # client sends partial DATA frame and closes connection
171
172 TODO: {
173 todo_skip 'use-after-free', 1 unless $ENV{TEST_NGINX_UNSAFE}
174 or $t->has_version('1.11.2');
175
176 my $s = Test::Nginx::HTTP2->new();
177 my $s2 = Test::Nginx::HTTP2->new();
178
179 $s->new_stream({ path => '/abort', body_more => 1 });
180 $s->h2_body('TEST', { split => [ 9 ], abort => 1 });
181
182 close $s->{socket};
183
184 $s2->h2_ping('PING');
185 isnt(@{$s2->read()}, 0, 'chunked abort');
186
187 }
162 188
163 ############################################################################### 189 ###############################################################################
164 190
165 sub get_body { 191 sub get_body {
166 my ($url, %extra) = @_; 192 my ($url, %extra) = @_;