mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Handle conditional get in live requests - this will prevent error when using stale on live streams(issue #9636)
This commit is contained in:
parent
36f7732e82
commit
2651b597f2
2 changed files with 19 additions and 0 deletions
|
@ -98,6 +98,10 @@ module ActionController
|
|||
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 @@ module ActionController
|
|||
end
|
||||
response.stream.close
|
||||
end
|
||||
|
||||
def with_stale
|
||||
render :text => 'stale' if stale?(:etag => "123")
|
||||
end
|
||||
end
|
||||
|
||||
tests TestController
|
||||
|
@ -117,5 +121,16 @@ module ActionController
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue