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

- (Object) net_http_res (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

+ (Object) included(receiver)



29
30
31
# File 'lib/restclient/mixin/response.rb', line 29

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

Instance Method Details

- (Object) code

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

- (Object) cookies

Hash of cookies extracted from response headers



19
20
21
22
23
24
25
26
27
# File 'lib/restclient/mixin/response.rb', line 19

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

- (Object) headers

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