Handle conditional get in live requests - this will prevent error when using stale on live streams(issue #9636)

This commit is contained in:
Bernard Potocki 2013-03-14 09:13:10 +01:00
parent 36f7732e82
commit 2651b597f2
2 changed files with 19 additions and 0 deletions

@ -98,6 +98,10 @@ def build_buffer(response, body)
def merge_default_headers(original, default)
Header.new self, super
end
def handle_conditional_get!
super unless committed?
end
end
def process(name)

@ -48,6 +48,10 @@ def thread_locals
end
response.stream.close
end
def with_stale
render :text => 'stale' if stale?(:etag => "123")
end
end
tests TestController
@ -117,5 +121,16 @@ def test_render_text
assert_equal 'zomg', response.body
assert response.stream.closed?, 'stream should be closed'
end
def test_stale_without_etag
get :with_stale
assert_equal 200, @response.status.to_i
end
def test_stale_with_etag
@request.if_none_match = Digest::MD5.hexdigest("123")
get :with_stale
assert_equal 304, @response.status.to_i
end
end
end