diff options
author | Eric Wong <e@80x24.org> | 2015-03-14 02:49:47 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-03-14 02:54:19 +0000 |
commit | 404eed25354998f69a56205adc6ea70f3306216f (patch) | |
tree | 2418799223f8089553d69d08e1f3c429efbc6210 /lib | |
parent | bec46d9d2675771a183c934114fe86700e09c39e (diff) | |
download | yahns-404eed25354998f69a56205adc6ea70f3306216f.tar.gz |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/yahns/http_client.rb | 7 |
1 files 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 |