comparison h2_proxy_request_buffering_ssl.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 29aa547dd963
children 4dc302d8e04f
comparison
equal deleted inserted replaced
944:235f796c2861 945:d73bef563aea
131 '56789many', 'many - part 2'); 131 '56789many', 'many - part 2');
132 is($f->{http_end}(), 200, 'many - response'); 132 is($f->{http_end}(), 200, 'many - response');
133 133
134 $f = get_body('/', 'content-length' => 0); 134 $f = get_body('/', 'content-length' => 0);
135 ok($f->{headers}, 'empty'); 135 ok($f->{headers}, 'empty');
136 is($f->{upload}('', body_more => 1), '', 'empty - part'); 136 is($f->{upload}('', body_more => 1, wait => 0.2), '', 'empty - part');
137 is($f->{upload}(''), '', 'empty - part 2'); 137 is($f->{upload}('', wait => 0.2), '', 'empty - part 2');
138 is($f->{http_end}(), 200, 'empty - response'); 138 is($f->{http_end}(), 200, 'empty - response');
139 139
140 $f = get_body('/', 'content-length' => 10); 140 $f = get_body('/', 'content-length' => 10);
141 ok($f->{headers}, 'split'); 141 ok($f->{headers}, 'split');
142 is($f->{upload}('0123456789', split => [ 14 ]), '0123456789', 'split'); 142 is($f->{upload}('0123456789', split => [ 14 ]), '0123456789', 'split');
172 'chunked many - part 2'); 172 'chunked many - part 2');
173 is($f->{http_end}(), 200, 'chunked many - response'); 173 is($f->{http_end}(), 200, 'chunked many - response');
174 174
175 $f = get_body('/chunked'); 175 $f = get_body('/chunked');
176 ok($f->{headers}, 'chunked empty'); 176 ok($f->{headers}, 'chunked empty');
177 is($f->{upload}('', body_more => 1), '', 'chunked empty - part'); 177 is($f->{upload}('', body_more => 1, wait => 0.2), '', 'chunked empty - part');
178 is($f->{upload}(''), '0' . CRLF . CRLF, 'chunked empty - part 2'); 178 is($f->{upload}(''), '0' . CRLF . CRLF, 'chunked empty - part 2');
179 is($f->{http_end}(), 200, 'chunked empty - response'); 179 is($f->{http_end}(), 200, 'chunked empty - response');
180 180
181 $f = get_body('/chunked'); 181 $f = get_body('/chunked');
182 ok($f->{headers}, 'chunked split'); 182 ok($f->{headers}, 'chunked split');
220 $f->{headers} = raw_read($client, '', 1, \&log2i); 220 $f->{headers} = raw_read($client, '', 1, \&log2i);
221 221
222 my $chunked = $f->{headers} =~ /chunked/; 222 my $chunked = $f->{headers} =~ /chunked/;
223 223
224 my $body_read = sub { 224 my $body_read = sub {
225 my ($s, $buf, $len) = @_; 225 my ($s, $buf, $len, $wait) = @_;
226 226
227 for (1 .. 10) { 227 for (1 .. 10) {
228 $buf = raw_read($s, $buf, length($buf) + 1, \&log2i) 228 $buf = raw_read($s, $buf, length($buf) + 1, \&log2i,
229 or return ''; 229 $wait) or return '';
230 230
231 my $got = 0; 231 my $got = 0;
232 $got += $chunked ? hex $_ : $_ for $chunked 232 $got += $chunked ? hex $_ : $_ for $chunked
233 ? $buf =~ /(\w+)\x0d\x0a?\w+\x0d\x0a?/g 233 ? $buf =~ /(\w+)\x0d\x0a?\w+\x0d\x0a?/g
234 : length($buf); 234 : length($buf);
241 $f->{upload} = sub { 241 $f->{upload} = sub {
242 my ($body, %extra) = @_; 242 my ($body, %extra) = @_;
243 243
244 h2_body($sess, $body, { %extra }); 244 h2_body($sess, $body, { %extra });
245 245
246 return $body_read->($client, '', length($body)); 246 return $body_read->($client, '', length($body), $extra{wait});
247 }; 247 };
248 $f->{http_end} = sub { 248 $f->{http_end} = sub {
249 $client->write(<<EOF); 249 $client->write(<<EOF);
250 HTTP/1.1 200 OK 250 HTTP/1.1 200 OK
251 Connection: close 251 Connection: close