Skip to content

Commit

Permalink
Save reason phrase in Protocol::HTTP1::Response
Browse files Browse the repository at this point in the history
Save away the raw reason phrase provided by the server. This is of
limited niche value, as the reason phrase seems to be _mostly_
unused/ignored.

One example of where it's needed:

The [Proxmox VE API](https://pve.proxmox.com/wiki/Proxmox_VE_API)
ships error reason strings back using the HTTP reason phrase. Without
this side-channel, error status is 100% opaque/unavailable.
  • Loading branch information
uberjay committed Oct 23, 2023
1 parent 26a52f0 commit 44c1e8a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/async/http/protocol/http1/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ def self.read(connection, request)

UPGRADE = 'upgrade'

# @param reason [String] HTTP response line reason, ignored.
# @param 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,6 +31,10 @@ def initialize(connection, version, status, reason, headers, body)
def connection
@connection
end

def reason
@reason
end

def hijack?
@body.nil?
Expand Down

0 comments on commit 44c1e8a

Please sign in to comment.