Class: Posthaste::Response
- Inherits:
-
Struct
- Object
- Struct
- Posthaste::Response
- Defined in:
- lib/posthaste/http_client.rb
Overview
One HTTP response, in the shape the retry loop wants.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#header(name) ⇒ Object
HTTP header names are not case-sensitive and the sources these come from disagree about casing: Net::HTTP preserves what the server sent, a hand-written test double does whatever its author typed.
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
16 17 18 |
# File 'lib/posthaste/http_client.rb', line 16 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers
16 17 18 |
# File 'lib/posthaste/http_client.rb', line 16 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status
16 17 18 |
# File 'lib/posthaste/http_client.rb', line 16 def status @status end |
Instance Method Details
#header(name) ⇒ Object
HTTP header names are not case-sensitive and the sources these come from disagree about casing: Net::HTTP preserves what the server sent, a hand-written test double does whatever its author typed.
20 21 22 23 24 |
# File 'lib/posthaste/http_client.rb', line 20 def header(name) wanted = name.to_s.downcase pair = (headers || {}).find { |k, _| k.to_s.downcase == wanted } pair && pair[1] end |