From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: yahns-public@yhbt.net Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EDA9D1FA71 for ; Sat, 4 Apr 2015 01:08:20 +0000 (UTC) From: Eric Wong To: yahns-public@yhbt.net Subject: [PATCH 3/4] proxy_pass: expand pipelining tests for after-upload behavior Date: Sat, 4 Apr 2015 01:08:15 +0000 Message-Id: <1428109696-14564-4-git-send-email-e@80x24.org> In-Reply-To: <1428109696-14564-1-git-send-email-e@80x24.org> References: <1428109696-14564-1-git-send-email-e@80x24.org> List-Id: Pipelining uploads is rare in practice, but they must behave properly in case some brave soul wants to start doing it. --- test/test_proxy_pass.rb | 51 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/test/test_proxy_pass.rb b/test/test_proxy_pass.rb index cebd004..163a0f7 100644 --- a/test/test_proxy_pass.rb +++ b/test/test_proxy_pass.rb @@ -286,21 +286,44 @@ def check_pipelining(host, port) r2 << pl.readpartial(666) end - if false - pl.write "ET / HTTP/1.1\r\nHost: example.com\r\n\r\n" - until r3 =~ /hi\n/ - r3 << pl.readpartial(666) - end - else - pl.write "UT / HTTP/1.1\r\nHost: example.com\r\n" - pl.write "Transfer-Encoding: chunked\r\n\r\n" - pl.write "6\r\nchunky\r\n" - pl.write "0\r\n\r\n" - - until r3 =~ /chunky/ - r3 << pl.readpartial(666) - end + pl.write "UT / HTTP/1.1\r\nHost: example.com\r\n" + pl.write "Transfer-Encoding: chunked\r\n\r\n" + pl.write "6\r\nchunky\r\n" + pl.write "0\r\n\r\n" + + until r3 =~ /chunky/ + r3 << pl.readpartial(666) + end + + # ensure stuff still works after a chunked upload: + pl.write "GET / HTTP/1.1\r\nHost: example.com\r\n\r\nP" + after_up = '' + until after_up =~ /hi\n/ + after_up << pl.readpartial(666) + end + re = /^Date:[^\r\n]+/ + assert_equal after_up.sub(re, ''), r1.sub(re, '') + + # another upload, this time without chunking + pl.write "UT / HTTP/1.1\r\nHost: example.com\r\n" + pl.write "Content-Length: 8\r\n\r\n" + pl.write "identity" + identity = '' + + until identity =~ /identity/ + identity << pl.readpartial(666) + end + assert_match %r{identity\z}, identity + assert_match %r{\AHTTP/1\.1 201\b}, identity + + # ensure stuff still works after an identity upload: + pl.write "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n" + after_up = '' + until after_up =~ /hi\n/ + after_up << pl.readpartial(666) end + re = /^Date:[^\r\n]+/ + assert_equal after_up.sub(re, ''), r1.sub(re, '') end r1 = r1.split("\r\n").reject { |x| x =~ /^Date: / } r2 = r2.split("\r\n").reject { |x| x =~ /^Date: / } -- EW