yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
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	[thread overview]
Message-ID: <1428109696-14564-4-git-send-email-e@80x24.org> (raw)
In-Reply-To: <1428109696-14564-1-git-send-email-e@80x24.org>

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


  parent reply	other threads:[~2015-04-04  1:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-04  1:08 [PATCH 0/4] proxy_pass updates Eric Wong
2015-04-04  1:08 ` [PATCH 1/4] proxy_pass: test and fix larger uploads Eric Wong
2015-04-04  1:08 ` [PATCH 2/4] proxy_pass: test for truncated response behavior Eric Wong
2015-04-04  1:08 ` Eric Wong [this message]
2015-04-04  1:08 ` [PATCH 4/4] proxy_pass: more tests for giant headers and truncations Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/yahns/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428109696-14564-4-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=yahns-public@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/yahns.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).