In Files

  • lib/restclient/mixin/response.rb

RestClient::Mixin::Response

Attributes

net_http_res[R]

Public Class Methods

included(receiver) click to toggle source
 
               # File lib/restclient/mixin/response.rb, line 31
def self.included(receiver)
        receiver.extend(RestClient::Mixin::Response::ClassMethods)
end
            

Public Instance Methods

code() click to toggle source

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

 
               # File lib/restclient/mixin/response.rb, line 8
def code
        @code ||= @net_http_res.code.to_i
end
            
cookies() click to toggle source

Hash of cookies extracted from response headers

 
               # File lib/restclient/mixin/response.rb, line 19
def cookies
        @cookies ||= (self.headers[:set_cookie] || []).inject({}) do |out, cookie|
                cookie.split('; ').each do |raw_c|
                        key, val = raw_c.split('=')
                        unless %w(expires domain path secure).member?(key)
                                out[key] = val
                        end
                end
                out
        end
end
            
headers() click to toggle source

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

 
               # File lib/restclient/mixin/response.rb, line 14
def headers
        @headers ||= self.class.beautify_headers(@net_http_res.to_hash)
end