Class: HyperSpec::Response
- Inherits:
-
Struct
- Object
- Struct
- HyperSpec::Response
- Defined in:
- lib/hyperspec.rb
Constant Summary collapse
- STATI =
{ # 2xx 200 => :ok, 201 => :created, # 4xx 401 => :unauthorized, 411 => :length_required, # WebDav extensions 422 => :unprocessable_entity, }
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
130 131 132 |
# File 'lib/hyperspec.rb', line 130 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers
130 131 132 |
# File 'lib/hyperspec.rb', line 130 def headers @headers end |
#status_code ⇒ Object
Returns the value of attribute status_code
130 131 132 |
# File 'lib/hyperspec.rb', line 130 def status_code @status_code end |
Class Method Details
.from_net_http_response(http) ⇒ Object
144 145 146 147 148 149 150 151 152 |
# File 'lib/hyperspec.rb', line 144 def self.from_net_http_response(http) status_code = http.code.to_i body = http.body headers = CaseInsensitiveHash.from_hash(http.to_hash) new(status_code, headers, body) end |
Instance Method Details
#content_charset ⇒ Object
158 159 160 |
# File 'lib/hyperspec.rb', line 158 def content_charset (md = headers['Content-Type'].match(/;charset=(.*)/)) && md[1] end |
#content_type ⇒ Object
154 155 156 |
# File 'lib/hyperspec.rb', line 154 def content_type headers['Content-Type'].split(';').first end |
#status ⇒ Object
162 163 164 |
# File 'lib/hyperspec.rb', line 162 def status STATI[status_code] end |