# HG changeset patch # User Sergey Kandaurov # Date 1515767002 -10800 # Node ID 6ca8b38f63b61c6c00ac4c9e355a7909dbb6aeb2 # Parent 6f0e68970b94d83849f544dcf50334dcce754f24 Tests: relaxed proxy_request_buffering tests to pass on slow hosts. Split DATA frame could be proxied in a single chunk. diff --git a/h2_proxy_request_buffering.t b/h2_proxy_request_buffering.t --- a/h2_proxy_request_buffering.t +++ b/h2_proxy_request_buffering.t @@ -156,9 +156,8 @@ is($f->{http_end}(), 200, 'chunked empty $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 @@ isnt(@{$s2->read()}, 0, 'chunked abort') ############################################################################### +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); diff --git a/h2_proxy_request_buffering_ssl.t b/h2_proxy_request_buffering_ssl.t --- a/h2_proxy_request_buffering_ssl.t +++ b/h2_proxy_request_buffering_ssl.t @@ -175,13 +175,25 @@ is($f->{http_end}(), 200, 'chunked empty $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);