Class: Faraday::Response

### Home Classes Methods

### In Files

- lib/faraday/autoload.rb
- lib/faraday/response.rb

### Parent

Object

### Namespace

- CLASS Faraday::Response::Logger
- CLASS Faraday::Response::Middleware
- CLASS Faraday::Response::RaiseError

### Methods

- ::new
- #apply_request
- #body
- #finish
- #finished?
- #headers
- #marshal_dump
- #marshal_load
- #on_complete
- #status
- #success?

### Class/Module Index

Quicksearch

- Faraday
- Faraday::Adapter
- Faraday::Adapter::EMHttp
- Faraday::Adapter::EMHttp::Manager
- Faraday::Adapter::EMHttp::Options
- Faraday::Adapter::EMSynchrony
- Faraday::Adapter::EMSynchrony::ParallelManager
- Faraday::Adapter::Excon
- Faraday::Adapter::HTTPClient
- Faraday::Adapter::NetHttp
- Faraday::Adapter::NetHttpPersistent
- Faraday::Adapter::Parallelism
- Faraday::Adapter::Patron
- Faraday::Adapter::Rack
- Faraday::Adapter::Test
- Faraday::Adapter::Test::Stub
- Faraday::Adapter::Test::Stubs
- Faraday::Adapter::Test::Stubs::NotFound
- Faraday::Adapter::Typhoeus
- Faraday::AutoloadHelper
- Faraday::ClientError
- Faraday::CompositeReadIO
- Faraday::Connection
- Faraday::ConnectionFailed
- Faraday::ConnectionOptions
- Faraday::Env
- Faraday::Error
- Faraday::FlatParamsEncoder
- Faraday::Middleware
- Faraday::MiddlewareRegistry
- Faraday::MissingDependency
- Faraday::NestedParamsEncoder
- Faraday::Options
- Faraday::ParsingError
- Faraday::ProxyOptions
- Faraday::RackBuilder
- Faraday::RackBuilder::Handler
- Faraday::RackBuilder::StackLocked
- Faraday::Request
- Faraday::Request::Authorization
- Faraday::Request::BasicAuthentication
- Faraday::Request::Instrumentation
- Faraday::Request::Instrumentation::Options
- Faraday::Request::Multipart
- Faraday::Request::Retry
- Faraday::Request::Retry::Options
- Faraday::Request::TokenAuthentication
- Faraday::Request::UrlEncoded
- Faraday::RequestOptions
- Faraday::ResourceNotFound
- Faraday::Response
- Faraday::Response::Logger
- Faraday::Response::Middleware
- Faraday::Response::RaiseError
- Faraday::SSLError
- Faraday::SSLOptions
- Faraday::TimeoutError
- Faraday::Utils
- Faraday::Utils::Headers
- Faraday::Utils::ParamsHash
- EmHttpSslPatch
- Object

No matching classes.

# Faraday::Response

### Attributes

env[R]

### Public Class Methods

new(env = nil) click to toggle source

    # File lib/faraday/response.rb, line 27
    def initialize(env = nil)
      @env = Env.from(env) if env
      @on_complete_callbacks = []
    end

### Public Instance Methods

apply_request(request_env) click to toggle source

Expand the env with more properties, without overriding existing ones. Useful for applying request params after restoring a marshalled Response.

    # File lib/faraday/response.rb, line 87
    def apply_request(request_env)
      raise "response didn't finish yet" unless finished?
      @env = Env.from(request_env).update(@env)
      return self
    end

body() click to toggle source

    # File lib/faraday/response.rb, line 45
    def body
      finished? ? env.body : nil
    end

finish(env) click to toggle source

    # File lib/faraday/response.rb, line 62
    def finish(env)
      raise "response already finished" if finished?
      @on_complete_callbacks.each { |callback| callback.call(env) }
      @env = Env.from(env)
      return self
    end

finished?() click to toggle source

    # File lib/faraday/response.rb, line 49
    def finished?
      !!env
    end

headers() click to toggle source

    # File lib/faraday/response.rb, line 40
    def headers
      finished? ? env.response_headers : {}
    end

marshal_dump() click to toggle source

because @on_complete_callbacks cannot be marshalled

    # File lib/faraday/response.rb, line 74
    def marshal_dump
      !finished? ? nil : {
        :status => @env.status, :body => @env.body,
        :response_headers => @env.response_headers
      }
    end

marshal_load(env) click to toggle source

    # File lib/faraday/response.rb, line 81
    def marshal_load(env)
      @env = Env.from(env)
    end

on_complete() click to toggle source

    # File lib/faraday/response.rb, line 53
    def on_complete
      if not finished?
        @on_complete_callbacks << Proc.new
      else
        yield(env)
      end
      return self
    end

status() click to toggle source

    # File lib/faraday/response.rb, line 36
    def status
      finished? ? env.status : nil
    end

success?() click to toggle source

    # File lib/faraday/response.rb, line 69
    def success?
      finished? && env.success?
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.