diff options
author | Eric Wong <e@80x24.org> | 2016-05-12 02:16:25 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-05-12 02:23:48 +0000 |
commit | 2c95a6e5bc18ac860ec0f7f7614ffb4aa6ad817d (patch) | |
tree | b4e7648d1c897d1a3db81464e9bb5f125f01230d | |
parent | 9073125f71afd615091f575d74ec468a0b1b79bf (diff) | |
download | rack-webrick-header-each.tar.gz |
webrick: detect partial hijack without hash headers webrick-header-each
Response headers need not be a hash according to SPEC, so grab the io_lambda the first time we iterate through the headers and avoid an extra hash lookup.
-rw-r--r-- | lib/rack/handler/webrick.rb | 8 | ||||
-rw-r--r-- | test/spec_webrick.rb | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/rack/handler/webrick.rb b/lib/rack/handler/webrick.rb index 95aa8927..d0fcd213 100644 --- a/lib/rack/handler/webrick.rb +++ b/lib/rack/handler/webrick.rb @@ -86,10 +86,11 @@ module Rack status, headers, body = @app.call(env) begin res.status = status.to_i + io_lambda = nil headers.each { |k, vs| - next if k.downcase == RACK_HIJACK - - if k.downcase == "set-cookie" + if k == RACK_HIJACK + io_lambda = vs + elsif k.downcase == "set-cookie" res.cookies.concat vs.split("\n") else # Since WEBrick won't accept repeated headers, @@ -98,7 +99,6 @@ module Rack end } - io_lambda = headers[RACK_HIJACK] if io_lambda rd, wr = IO.pipe res.body = rd diff --git a/test/spec_webrick.rb b/test/spec_webrick.rb index 9ae6103d..4a10c1ca 100644 --- a/test/spec_webrick.rb +++ b/test/spec_webrick.rb @@ -171,7 +171,7 @@ describe Rack::Handler::WEBrick do Rack::Lint.new(lambda{ |req| [ 200, - {"rack.hijack" => io_lambda}, + [ [ "rack.hijack", io_lambda ] ], [""] ] }) |