From: Eric Wong <e@80x24.org>
To: yahns-public@yhbt.net
Subject: [[RFC]] http_client: hijack after 100-continue disables HTTP response
Date: Sat, 14 Mar 2015 02:56:08 +0000 [thread overview]
Message-ID: <1426301768-3825-1-git-send-email-e@80x24.org> (raw)
While rack.hijack usage during application dispatch normally
prevents yahns from writing an HTTP response out of the Rack
response array, this was not correctly prevented when the
application emitted a 100-continue response when the client
was was too slow to read the 100-continue response without
triggering response buffering the server.
This bug only affects exceeding rare apps which rely on both
rack.hijack use during app dispatch _and_ emits 100-continue
responses, and even then it only affects slow clients which
refuse to read the 100-continue response sent by yahns without
blocking.
---
lib/yahns/http_client.rb | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb
index 1c3c8dd..235decd 100644
--- a/lib/yahns/http_client.rb
+++ b/lib/yahns/http_client.rb
@@ -179,8 +179,9 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
handle_error(e)
end
+ # only called when buffering slow clients
# returns :wait_readable, :wait_writable, :ignore, or nil for epoll
- # returns false to keep looping inside yahns_step
+ # returns true to keep looping inside yahns_step
def r100_done
k = self.class
case k.input_buffering
@@ -193,7 +194,9 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
mkinput_preread # keep looping (@state == :body)
true
else # :lazy, false
- http_response_write(*k.app.call(@hs.env))
+ r = k.app.call(env = @hs.env)
+ return :ignore if env.include?(RACK_HIJACK_IO)
+ http_response_write(*r)
end
end
--
EW
next reply other threads:[~2015-03-14 2:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-14 2:56 Eric Wong [this message]
2015-03-16 21:10 ` [[RFC]] http_client: hijack after 100-continue disables HTTP response 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=1426301768-3825-1-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).