Class OAuth2::Response
In: lib/oauth2/response.rb
Parent: Object

Methods

body   content_type   headers   new   parsed   parser   register_parser   status  

Constants

PARSERS = { # Can't reliably detect whether MultiJson responds to load, since it's # a reserved word. Use adapter as a proxy for new features. :json => lambda{ |body| MultiJson.respond_to?(:adapter) ? MultiJson.load(body) : MultiJson.decode(body) rescue body }, :query => lambda{ |body| Rack::Utils.parse_query(body) }, :text => lambda{ |body| body }   Procs that, when called, will parse a response body according to the specified format.
CONTENT_TYPES = { 'application/json' => :json, 'text/javascript' => :json, 'application/x-www-form-urlencoded' => :query, 'text/plain' => :text   Content type assignments for various potential HTTP content types.

Attributes

error  [RW] 
options  [RW] 
response  [R] 

Public Class methods

Initializes a Response instance

@param [Faraday::Response] response The Faraday response instance @param [Hash] opts options in which to initialize the instance @option opts [Symbol] :parse (:automatic) how to parse the response body. one of :query (for x-www-form-urlencoded),

  :json, or :automatic (determined by Content-Type response header)

Adds a new content type parser.

@param [Symbol] key A descriptive symbol key such as :json or :query. @param [Array] One or more mime types to which this parser applies. @yield [String] A block returning parsed content.

Public Instance methods

The HTTP response body

Attempts to determine the content type of the response.

The HTTP response headers

The parsed response body.

  Will attempt to parse application/x-www-form-urlencoded and
  application/json Content-Type response bodies

Determines the parser that will be used to supply the content of parsed

The HTTP response status code

[Validate]