diff --git a/lib/async/http/protocol/http1/response.rb b/lib/async/http/protocol/http1/response.rb index 67e402d6..70c75fc3 100644 --- a/lib/async/http/protocol/http1/response.rb +++ b/lib/async/http/protocol/http1/response.rb @@ -18,9 +18,12 @@ def self.read(connection, request) UPGRADE = 'upgrade' - # @param reason [String] HTTP response line reason, ignored. + attr_reader :reason + + # @param reason [String] HTTP response line reason phrase def initialize(connection, version, status, reason, headers, body) @connection = connection + @reason = reason protocol = headers.delete(UPGRADE) @@ -30,7 +33,7 @@ def initialize(connection, version, status, reason, headers, body) def connection @connection end - + def hijack? @body.nil? end diff --git a/test/async/http/protocol/http11.rb b/test/async/http/protocol/http11.rb index af2497ff..67448c2a 100755 --- a/test/async/http/protocol/http11.rb +++ b/test/async/http/protocol/http11.rb @@ -46,6 +46,7 @@ def around expect(response).to be(:success?) expect(response.version).to be == "HTTP/1.1" expect(response.body).to be(:empty?) + expect(response.reason).to be == "OK" response.read end @@ -74,6 +75,12 @@ def around expect(response.read).to be == "Hello World!" end + + it "has access to the http reason phrase" do + response = client.head("/") + + expect(response.reason).to be == "It worked!" + end end end end