Skip to content

Commit

Permalink
Drop support for the SERVER_ADDR header
Browse files Browse the repository at this point in the history
Following up #42349 and
rack/rack#1573 the `SERVER_ADDR` header can be
dropped, considering that it's not required by the CGI spec.
  • Loading branch information
ricardotk002 committed Jun 2, 2021
1 parent b9f48d5 commit 093a4cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 6 additions & 0 deletions actionpack/CHANGELOG.md
@@ -1,3 +1,9 @@
* Drop support for the `SERVER_ADDR` header

Following up https://github.com/rack/rack/pull/1573 and https://github.com/rails/rails/pull/42349

*Ricardo Díaz*

* Set session options when initializing a basic session.

*Gannon McGibbon*
Expand Down
3 changes: 0 additions & 3 deletions actionpack/lib/action_dispatch/http/request.rb
Expand Up @@ -42,11 +42,8 @@ class Request
HTTP_NEGOTIATE HTTP_PRAGMA HTTP_CLIENT_IP
HTTP_X_FORWARDED_FOR HTTP_ORIGIN HTTP_VERSION
HTTP_X_CSRF_TOKEN HTTP_X_REQUEST_ID HTTP_X_FORWARDED_HOST
SERVER_ADDR
].freeze

# TODO: Remove SERVER_ADDR when we remove support to Rack 2.1.
# See https://github.com/rack/rack/commit/c173b188d81ee437b588c1e046a1c9f031dea550
ENV_METHODS.each do |env|
class_eval <<-METHOD, __FILE__, __LINE__ + 1
# frozen_string_literal: true
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/http/url.rb
Expand Up @@ -222,7 +222,7 @@ def raw_host_with_port
if forwarded = x_forwarded_host.presence
forwarded.split(/,\s?/).last
else
get_header("HTTP_HOST") || "#{server_name || server_addr}:#{get_header('SERVER_PORT')}"
get_header("HTTP_HOST") || "#{server_name}:#{get_header('SERVER_PORT')}"
end
end

Expand Down

0 comments on commit 093a4cd

Please sign in to comment.