From: Eric Wong <e@80x24.org>
To: yahns-public@yhbt.net
Subject: [PATCH 1/4] proxy_pass: test and fix larger uploads
Date: Sat, 4 Apr 2015 01:08:13 +0000 [thread overview]
Message-ID: <1428109696-14564-2-git-send-email-e@80x24.org> (raw)
In-Reply-To: <1428109696-14564-1-git-send-email-e@80x24.org>
We were incorrectly stashing the return value of detach_rbuf!
into the inter-thread buffer buffer which is bound to the client.
---
lib/yahns/proxy_pass.rb | 5 +++--
test/test_proxy_pass.rb | 22 +++++++++++++++++++++-
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/lib/yahns/proxy_pass.rb b/lib/yahns/proxy_pass.rb
index 09fb884..ec1fbcf 100644
--- a/lib/yahns/proxy_pass.rb
+++ b/lib/yahns/proxy_pass.rb
@@ -108,7 +108,7 @@ def send_req_body(req)
when Array
vec = rv # partial write, retry in case loop
when :wait_writable
- buf = detach_rbuf!
+ detach_rbuf!
req[0] = vec
return :wait_writable
when nil
@@ -120,13 +120,14 @@ def send_req_body(req)
# note: we do not send any trailer, they are folded into the header
# because this relies on full request buffering
send_req_buf("0\r\n\r\n".freeze)
+ # prepare_wait_readable already called by send_req_buf
else # identity request, easy:
while input.read(0x2000, buf)
case rv = kgio_trywrite(buf)
when String
buf = rv # partial write, retry in case loop
when :wait_writable
- buf = detach_rbuf!
+ detach_rbuf!
req[0] = buf
return :wait_writable
when nil
diff --git a/test/test_proxy_pass.rb b/test/test_proxy_pass.rb
index 5bf8722..53542ac 100644
--- a/test/test_proxy_pass.rb
+++ b/test/test_proxy_pass.rb
@@ -144,6 +144,7 @@ def test_proxy_pass
cfg.instance_eval do
app(:rack, Yahns::ProxyPass.new("http://#{host2}:#{port2}")) do
listen "#{host}:#{port}"
+ client_max_body_size nil
end
stderr_path err.path
end
@@ -154,6 +155,7 @@ def test_proxy_pass
cfg.instance_eval do
app(:rack, ProxiedApp.new) do
listen "#{host2}:#{port2}"
+ client_max_body_size nil
end
stderr_path err.path
end
@@ -195,7 +197,7 @@ def test_proxy_pass
assert_equal 'text/PAIN', res['Content-Type']
assert_equal 'HIHIHI!', res.body
- # normal content-length
+ # normal content-length (PUT)
gplv3.rewind
req = Net::HTTP::Put.new('/')
req.body_stream = gplv3
@@ -210,6 +212,24 @@ def test_proxy_pass
res = http.request(Net::HTTP::Get.new('/giant-body'))
assert_equal 200, res.code.to_i
assert_equal OMFG, res.body
+
+ # giant PUT content-length
+ req = Net::HTTP::Put.new('/')
+ req.body_stream = StringIO.new(OMFG)
+ req.content_type = 'application/octet-stream'
+ req.content_length = OMFG.size
+ res = http.request(req)
+ assert_equal OMFG, res.body
+ assert_equal 201, res.code.to_i
+
+ # giant PUT chunked encoding
+ req = Net::HTTP::Put.new('/')
+ req.body_stream = StringIO.new(OMFG)
+ req.content_type = 'application/octet-stream'
+ req['Transfer-Encoding'] = 'chunked'
+ res = http.request(req)
+ assert_equal OMFG, res.body
+ assert_equal 201, res.code.to_i
end
# ensure we do not chunk responses back to an HTTP/1.0 client even if
--
EW
next prev 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 ` Eric Wong [this message]
2015-04-04 1:08 ` [PATCH 2/4] proxy_pass: test for truncated response behavior Eric Wong
2015-04-04 1:08 ` [PATCH 3/4] proxy_pass: expand pipelining tests for after-upload behavior Eric Wong
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-2-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).