comparison h2_proxy_request_buffering.t @ 945:d73bef563aea

Tests: speed up HTTP/2 tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 15 Jun 2016 13:27:56 +0300
parents d3ff66fc7f5c
children 4dc302d8e04f
comparison
equal deleted inserted replaced
944:235f796c2861 945:d73bef563aea
97 '56789many', 'many - part 2'); 97 '56789many', 'many - part 2');
98 is($f->{http_end}(), 200, 'many - response'); 98 is($f->{http_end}(), 200, 'many - response');
99 99
100 $f = get_body('/', 'content-length' => 0); 100 $f = get_body('/', 'content-length' => 0);
101 ok($f->{headers}, 'empty'); 101 ok($f->{headers}, 'empty');
102 is($f->{upload}('', body_more => 1), '', 'empty - part'); 102 is($f->{upload}('', body_more => 1, wait => 0.2), '', 'empty - part');
103 is($f->{upload}(''), '', 'empty - part 2'); 103 is($f->{upload}('', wait => 0.2), '', 'empty - part 2');
104 is($f->{http_end}(), 200, 'empty - response'); 104 is($f->{http_end}(), 200, 'empty - response');
105 105
106 $f = get_body('/', 'content-length' => 1536); 106 $f = get_body('/', 'content-length' => 1536);
107 ok($f->{headers}, 'buffer'); 107 ok($f->{headers}, 'buffer');
108 is($f->{upload}('0123' x 128, body_more => 1), '0123' x 128, 108 is($f->{upload}('0123' x 128, body_more => 1), '0123' x 128,
147 'chunked many - part 2'); 147 'chunked many - part 2');
148 is($f->{http_end}(), 200, 'chunked many - response'); 148 is($f->{http_end}(), 200, 'chunked many - response');
149 149
150 $f = get_body('/chunked'); 150 $f = get_body('/chunked');
151 ok($f->{headers}, 'chunked empty'); 151 ok($f->{headers}, 'chunked empty');
152 is($f->{upload}('', body_more => 1), '', 'chunked empty - part'); 152 is($f->{upload}('', body_more => 1, wait => 0.2), '', 'chunked empty - part');
153 is($f->{upload}(''), '0' . CRLF . CRLF, 'chunked empty - part 2'); 153 is($f->{upload}(''), '0' . CRLF . CRLF, 'chunked empty - part 2');
154 is($f->{http_end}(), 200, 'chunked empty - response'); 154 is($f->{http_end}(), 200, 'chunked empty - response');
155 155
156 $f = get_body('/chunked'); 156 $f = get_body('/chunked');
157 ok($f->{headers}, 'chunked split'); 157 ok($f->{headers}, 'chunked split');
195 $f->{headers} = raw_read($client, '', 1, \&log2i); 195 $f->{headers} = raw_read($client, '', 1, \&log2i);
196 196
197 my $chunked = $f->{headers} =~ /chunked/; 197 my $chunked = $f->{headers} =~ /chunked/;
198 198
199 my $body_read = sub { 199 my $body_read = sub {
200 my ($s, $buf, $len) = @_; 200 my ($s, $buf, $len, $wait) = @_;
201 201
202 for (1 .. 10) { 202 for (1 .. 10) {
203 $buf = raw_read($s, $buf, length($buf) + 1, \&log2i) 203 $buf = raw_read($s, $buf, length($buf) + 1, \&log2i,
204 or return ''; 204 $wait) or return '';
205 205
206 my $got = 0; 206 my $got = 0;
207 $got += $chunked ? hex $_ : $_ for $chunked 207 $got += $chunked ? hex $_ : $_ for $chunked
208 ? $buf =~ /(\w+)\x0d\x0a?\w+\x0d\x0a?/g 208 ? $buf =~ /(\w+)\x0d\x0a?\w+\x0d\x0a?/g
209 : length($buf); 209 : length($buf);
216 $f->{upload} = sub { 216 $f->{upload} = sub {
217 my ($body, %extra) = @_; 217 my ($body, %extra) = @_;
218 218
219 h2_body($sess, $body, { %extra }); 219 h2_body($sess, $body, { %extra });
220 220
221 return $body_read->($client, '', length($body)); 221 return $body_read->($client, '', length($body), $extra{wait});
222 }; 222 };
223 $f->{http_end} = sub { 223 $f->{http_end} = sub {
224 $client->write(<<EOF); 224 $client->write(<<EOF);
225 HTTP/1.1 200 OK 225 HTTP/1.1 200 OK
226 Connection: close 226 Connection: close