Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/async/http/protocol/http1/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ def self.read(connection, request)

UPGRADE = 'upgrade'

# @param reason [String] HTTP response line reason, ignored.
# @attribute [String] The HTTP response line reason.
attr :reason

# @parameter reason [String] HTTP response line reason phrase
def initialize(connection, version, status, reason, headers, body)
@connection = connection
@reason = reason

protocol = headers.delete(UPGRADE)

Expand All @@ -30,7 +34,7 @@ def initialize(connection, version, status, reason, headers, body)
def connection
@connection
end

def hijack?
@body.nil?
end
Expand Down
7 changes: 7 additions & 0 deletions test/async/http/protocol/http11.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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