Skip to content

Commit

Permalink
Remove SERVER_ADDR.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Feb 7, 2020
1 parent d902198 commit c173b18
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ All notable changes to this project will be documented in this file. For info on
- Deprecation of `Rack::File`. It will be deprecated again in rack 2.2 or 3.0. ([@rafaelfranca](https://github.com/rafaelfranca))
- Support for Ruby 2.2 as it is well past EOL. ([@ioquatix](https://github.com/ioquatix))
- Remove `Rack::Files#response_body` as the implementation was broken. ([#1153](https://github.com/rack/rack/pull/1153), [@ioquatix](https://github.com/ioquatix))
- Remove `SERVER_ADDR` which was never part of the original SPEC. ([#1573](https://github.com/rack/rack/pull/1573), [@ioquatix](https://github.com/ioquatix))

### Fixed

Expand Down
1 change: 0 additions & 1 deletion lib/rack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module Rack
QUERY_STRING = 'QUERY_STRING'
SERVER_PROTOCOL = 'SERVER_PROTOCOL'
SERVER_NAME = 'SERVER_NAME'
SERVER_ADDR = 'SERVER_ADDR'
SERVER_PORT = 'SERVER_PORT'
CACHE_CONTROL = 'Cache-Control'
EXPIRES = 'Expires'
Expand Down
10 changes: 3 additions & 7 deletions lib/rack/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ def authority
forwarded_authority || host_authority || server_authority
end

# The authority as defined by the `SERVER_NAME`/`SERVER_ADDR` and
# `SERVER_PORT` variables.
# The authority as defined by the `SERVER_NAME` and `SERVER_PORT`
# variables.
def server_authority
host = self.server_name
port = self.server_port
Expand All @@ -244,11 +244,7 @@ def server_authority
end

def server_name
if name = get_header(SERVER_NAME)
name
elsif address = get_header(SERVER_ADDR)
wrap_ipv6(address)
end
get_header(SERVER_NAME)
end

def server_port
Expand Down
6 changes: 0 additions & 6 deletions test/spec_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ class RackRequestTest < Minitest::Spec
req.host.must_equal "[2001:db8:cafe::17]"
req.hostname.must_equal "2001:db8:cafe::17"

env = Rack::MockRequest.env_for("/", "SERVER_ADDR" => "192.168.1.1", "SERVER_PORT" => "9292")
env.delete("SERVER_NAME")
req = make_request(env)
req.host.must_equal "192.168.1.1"
req.hostname.must_equal "192.168.1.1"

env = Rack::MockRequest.env_for("/")
env.delete("SERVER_NAME")
req = make_request(env)
Expand Down

0 comments on commit c173b18

Please sign in to comment.