summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/rack/lint.rb9
-rw-r--r--test/spec_lint.rb4
3 files changed, 10 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d6a8fbb1..808a7ce1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -40,6 +40,7 @@ All notable changes to this project will be documented in this file. For info on
### Fixed
+- `Lint` checks when response hijacking that `rack.hijack` is called with a valid object. ([@jeremyevans](https://github.com/jeremyevans))
- `Response#write` correctly updates `Content-Length` if initialized with a body. ([@jeremyevans](https://github.com/jeremyevans))
- `CommonLogger` includes `SCRIPT_NAME` when logging. ([@Erol](https://github.com/Erol))
- `Utils.parse_nested_query` correctly handles empty queries, using an empty instance of the params class instead of a hash. ([@jeremyevans](https://github.com/jeremyevans))
diff --git a/lib/rack/lint.rb b/lib/rack/lint.rb
index 7a79b77f..615a9813 100644
--- a/lib/rack/lint.rb
+++ b/lib/rack/lint.rb
@@ -61,7 +61,10 @@ module Rack
## the *headers*,
check_headers headers
- check_hijack_response headers, env
+ hijack_proc = check_hijack_response headers, env
+ if hijack_proc && headers.is_a?(Hash)
+ headers[RACK_HIJACK] = hijack_proc
+ end
## and the *body*.
check_content_type status, headers
@@ -614,7 +617,7 @@ module Rack
headers[RACK_HIJACK].respond_to? :call
}
original_hijack = headers[RACK_HIJACK]
- headers[RACK_HIJACK] = proc do |io|
+ proc do |io|
original_hijack.call HijackWrapper.new(io)
end
else
@@ -624,6 +627,8 @@ module Rack
assert('rack.hijack header must not be present if server does not support hijacking') {
headers[RACK_HIJACK].nil?
}
+
+ nil
end
end
## ==== Conventions
diff --git a/test/spec_lint.rb b/test/spec_lint.rb
index 7dec47cd..9823a9c6 100644
--- a/test/spec_lint.rb
+++ b/test/spec_lint.rb
@@ -622,8 +622,8 @@ describe Rack::Lint do
Rack::Lint.new(lambda { |env|
env['rack.hijack?'] = true
- [201, { "Content-type" => "text/plain", "Content-length" => "0", 'rack.hijack' => lambda { StringIO.new }, 'rack.hijack_io' => StringIO.new }, []]
- }).call(env({}))[1]['rack.hijack'].call.read.must_equal ''
+ [201, { "Content-type" => "text/plain", "Content-length" => "0", 'rack.hijack' => lambda {|io| io }, 'rack.hijack_io' => StringIO.new }, []]
+ }).call(env({}))[1]['rack.hijack'].call(StringIO.new).read.must_equal ''
end
end