Class: HttpClient::Response

Inherits:
String
  • Object
show all
Includes:
Mixin::Response
Defined in:
lib/http_client/response.rb

Overview

The response from HttpClient looks like a string, but is actually one of these. 99% of the time you’re making a http call all you care about is the body, but on the occassion you want to fetch the headers you can:

HttpClient.get('http://example.com').headers[:content_type]

Instance Attribute Summary

Attributes included from Mixin::Response

#net_http_res

Instance Method Summary collapse

Methods included from Mixin::Response

#code, #cookies, #headers, included

Constructor Details

#initialize(string, net_http_res) ⇒ Response

Returns a new instance of Response.



14
15
16
17
# File 'lib/http_client/response.rb', line 14

def initialize(string, net_http_res)
  @net_http_res = net_http_res
  super(string || "")
end