comparison h2_proxy_request_buffering.t @ 1271:6ca8b38f63b6

Tests: relaxed proxy_request_buffering tests to pass on slow hosts. Split DATA frame could be proxied in a single chunk.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 12 Jan 2018 17:23:22 +0300
parents 766bcbb632ee
children ea593a9bab09
comparison
equal deleted inserted replaced
1270:6f0e68970b94 1271:6ca8b38f63b6
154 is($f->{upload}(''), '0' . CRLF . CRLF, 'chunked empty - part 2'); 154 is($f->{upload}(''), '0' . CRLF . CRLF, 'chunked empty - part 2');
155 is($f->{http_end}(), 200, 'chunked empty - response'); 155 is($f->{http_end}(), 200, 'chunked empty - response');
156 156
157 $f = get_body('/chunked'); 157 $f = get_body('/chunked');
158 ok($f->{headers}, 'chunked split'); 158 ok($f->{headers}, 'chunked split');
159 is($f->{upload}('0123456789', split => [ 14 ]), 159 is(http_content($f->{upload}('0123456789', split => [ 14 ])),
160 '5' . CRLF . '01234' . CRLF . '5' . CRLF . '56789' . CRLF . 160 '0123456789', 'chunked split');
161 '0' . CRLF . CRLF, 'chunked split');
162 is($f->{http_end}(), 200, 'chunked split - response'); 161 is($f->{http_end}(), 200, 'chunked split - response');
163 162
164 # unbuffered request body, chunked transfer-encoding 163 # unbuffered request body, chunked transfer-encoding
165 # client sends partial DATA frame and closes connection 164 # client sends partial DATA frame and closes connection
166 165
174 173
175 $s2->h2_ping('PING'); 174 $s2->h2_ping('PING');
176 isnt(@{$s2->read()}, 0, 'chunked abort'); 175 isnt(@{$s2->read()}, 0, 'chunked abort');
177 176
178 ############################################################################### 177 ###############################################################################
178
179 sub http_content {
180 my ($body) = @_;
181 my $content = '';
182
183 while ($body =~ /\G\x0d?\x0a?([0-9a-f]+)\x0d\x0a?/gcmsi) {
184 my $len = hex($1);
185 $content .= substr($body, pos($body), $len);
186 pos($body) += $len;
187 }
188
189 return $content;
190 }
179 191
180 sub get_body { 192 sub get_body {
181 my ($url, %extra) = @_; 193 my ($url, %extra) = @_;
182 my ($server, $client, $f); 194 my ($server, $client, $f);
183 195