Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't call controller's headers method internally #45141

Merged
merged 1 commit into from May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions actionpack/lib/action_controller/metal/rendering.rb
Expand Up @@ -78,8 +78,8 @@ def _set_rendered_content_type(format)
end

def _set_vary_header
if self.headers["Vary"].blank? && request.should_apply_vary_header?
self.headers["Vary"] = "Accept"
if response.headers["Vary"].blank? && request.should_apply_vary_header?
response.headers["Vary"] = "Accept"
end
end

Expand Down
24 changes: 24 additions & 0 deletions actionpack/test/controller/integration_test.rb
Expand Up @@ -850,6 +850,30 @@ def app
end
end

class ControllerWithHeadersMethodIntegrationTest < ActionDispatch::IntegrationTest
class TestController < ActionController::Base
def index
render plain: "ok"
end

def headers
{}.freeze
end
end

test "doesn't call controller's headers method" do
with_routing do |routes|
routes.draw do
get "/ok" => "controller_with_headers_method_integration_test/test#index"
end

get "/ok"

assert_response 200
end
end
end

class UrlOptionsIntegrationTest < ActionDispatch::IntegrationTest
class FooController < ActionController::Base
def index
Expand Down