* [[RFC]] http_client: hijack after 100-continue disables HTTP response
@ 2015-03-14 2:56 Eric Wong
2015-03-16 21:10 ` Eric Wong
0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2015-03-14 2:56 UTC (permalink / raw)
To: yahns-public
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [[RFC]] http_client: hijack after 100-continue disables HTTP response
2015-03-14 2:56 [[RFC]] http_client: hijack after 100-continue disables HTTP response Eric Wong
@ 2015-03-16 21:10 ` Eric Wong
0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2015-03-16 21:10 UTC (permalink / raw)
To: yahns-public
pushed
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-16 21:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-14 2:56 [[RFC]] http_client: hijack after 100-continue disables HTTP response Eric Wong
2015-03-16 21:10 ` Eric Wong
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).