Permalink
Browse files

freeze the header object

  • Loading branch information...
tenderlove committed Jul 30, 2012
1 parent 619e7c8 commit b3d1f5b630debcc2d0572a3e3af1855ef93300c2
@@ -78,6 +78,11 @@ def initialize(status = 200, header = {}, body = [])
super(status, header, body)
end
+ def commit!
+ headers.freeze
+ super
+ end
+
private
def build_buffer(response, body)
@@ -44,6 +44,7 @@ def test_content_length_is_removed
def test_headers_cannot_be_written_after_write
@response.stream.write 'omg'
+ assert @response.headers.frozen?
e = assert_raises(ActionDispatch::IllegalStateError) do
@response.headers['Content-Length'] = "zomg"
end
@@ -54,6 +55,7 @@ def test_headers_cannot_be_written_after_write
def test_headers_cannot_be_written_after_close
@response.stream.close
+ assert @response.headers.frozen?
e = assert_raises(ActionDispatch::IllegalStateError) do
@response.headers['Content-Length'] = "zomg"
end

0 comments on commit b3d1f5b

Please sign in to comment.