1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #35400 from aglushkov/stream_manual_cache_control

Allow custom cache-control header in AC::Live
This commit is contained in:
Aaron Patterson 2019-02-25 13:33:22 -08:00 committed by GitHub
commit 790a3e69ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -146,7 +146,7 @@ module ActionController
def write(string)
unless @response.committed?
@response.set_header "Cache-Control", "no-cache"
@response.headers["Cache-Control"] ||= "no-cache"
@response.delete_header "Content-Length"
end

View file

@ -51,11 +51,17 @@ module ActionController
assert_equal ["omg"], @response.body_parts
end
def test_cache_control_is_set
def test_cache_control_is_set_by_default
@response.stream.write "omg"
assert_equal "no-cache", @response.headers["Cache-Control"]
end
def test_cache_control_is_set_manually
@response.set_header("Cache-Control", "public")
@response.stream.write "omg"
assert_equal "public", @response.headers["Cache-Control"]
end
def test_content_length_is_removed
@response.headers["Content-Length"] = "1234"
@response.stream.write "omg"