Class: Posthaste::Response

Inherits:
Struct
  • Object
show all
Defined in:
lib/posthaste/http_client.rb

Overview

One HTTP response, in the shape the retry loop wants.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



16
17
18
# File 'lib/posthaste/http_client.rb', line 16

def body
  @body
end

#headersObject

Returns the value of attribute headers

Returns:

  • (Object)

    the current value of headers



16
17
18
# File 'lib/posthaste/http_client.rb', line 16

def headers
  @headers
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of 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