Module: RestClient::Mixin::Response

Included in:
RawResponse, Response
Defined in:
lib/restclient/mixin/response.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#net_http_resObject (readonly)

Returns the value of attribute net_http_res.



4
5
6
# File 'lib/restclient/mixin/response.rb', line 4

def net_http_res
  @net_http_res
end

Class Method Details

.included(receiver) ⇒ Object



34
35
36
# File 'lib/restclient/mixin/response.rb', line 34

def self.included(receiver)
	receiver.extend(RestClient::Mixin::Response::ClassMethods)
end

Instance Method Details

#codeObject

HTTP status code, always 200 since RestClient throws exceptions for other codes.



8
9
10
# File 'lib/restclient/mixin/response.rb', line 8

def code
	@code ||= @net_http_res.code.to_i
end

#cookiesObject

Hash of cookies extracted from response headers



24
25
26
27
28
29
30
31
32
# File 'lib/restclient/mixin/response.rb', line 24

def cookies
	@cookies ||= (self.headers[:set_cookie] || "").split('; ').inject({}) do |out, raw_c|
		key, val = raw_c.split('=')
		unless %w(expires domain path secure).member?(key)
			out[key] = val
		end
		out
	end
end

#headersObject

A hash of the headers, beautified with symbols and underscores. e.g. “Content-type” will become :content_type.



14
15
16
# File 'lib/restclient/mixin/response.rb', line 14

def headers
	@headers ||= self.class.beautify_headers(@net_http_res.to_hash)
end

#raw_headersObject

The raw headers.



19
20
21
# File 'lib/restclient/mixin/response.rb', line 19

def raw_headers
	@raw_headers ||= @net_http_res.to_hash
end