Mercurial > hg > nginx-tests
changeset 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 | 6f0e68970b94 |
children | 01010d9021b8 |
files | h2_proxy_request_buffering.t h2_proxy_request_buffering_ssl.t |
diffstat | 2 files changed, 30 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/h2_proxy_request_buffering.t Thu Jan 11 22:46:07 2018 +0300 +++ b/h2_proxy_request_buffering.t Fri Jan 12 17:23:22 2018 +0300 @@ -156,9 +156,8 @@ $f = get_body('/chunked'); ok($f->{headers}, 'chunked split'); -is($f->{upload}('0123456789', split => [ 14 ]), - '5' . CRLF . '01234' . CRLF . '5' . CRLF . '56789' . CRLF . - '0' . CRLF . CRLF, 'chunked split'); +is(http_content($f->{upload}('0123456789', split => [ 14 ])), + '0123456789', 'chunked split'); is($f->{http_end}(), 200, 'chunked split - response'); # unbuffered request body, chunked transfer-encoding @@ -177,6 +176,19 @@ ############################################################################### +sub http_content { + my ($body) = @_; + my $content = ''; + + while ($body =~ /\G\x0d?\x0a?([0-9a-f]+)\x0d\x0a?/gcmsi) { + my $len = hex($1); + $content .= substr($body, pos($body), $len); + pos($body) += $len; + } + + return $content; +} + sub get_body { my ($url, %extra) = @_; my ($server, $client, $f);
--- a/h2_proxy_request_buffering_ssl.t Thu Jan 11 22:46:07 2018 +0300 +++ b/h2_proxy_request_buffering_ssl.t Fri Jan 12 17:23:22 2018 +0300 @@ -175,13 +175,25 @@ $f = get_body('/chunked'); ok($f->{headers}, 'chunked split'); -is($f->{upload}('0123456789', split => [ 14 ]), - '5' . CRLF . '01234' . CRLF . '5' . CRLF . '56789' . CRLF . - '0' . CRLF . CRLF, 'chunked split'); +is(http_content($f->{upload}('0123456789', split => [ 14 ])), + '0123456789', 'chunked split'); is($f->{http_end}(), 200, 'chunked split - response'); ############################################################################### +sub http_content { + my ($body) = @_; + my $content = ''; + + while ($body =~ /\G\x0d?\x0a?([0-9a-f]+)\x0d\x0a?/gcmsi) { + my $len = hex($1); + $content .= substr($body, pos($body), $len); + pos($body) += $len; + } + + return $content; +} + sub get_body { my ($url, %extra) = @_; my ($server, $client, $f);