class Faraday::Response

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/faraday/response.rbs

class Faraday::Response
  def status: () -> untyped
end

Response represents an HTTP response from making an HTTP request.

def apply_request(request_env)

Useful for applying request params after restoring a marshalled Response.
Expand the env with more properties, without overriding existing ones.
def apply_request(request_env)
  raise "response didn't finish yet" unless finished?
  @env = Env.from(request_env).update(@env)
  self
end

def body

def body
  finished? ? env.body : nil
end

def finish(env)

def finish(env)
  raise 'response already finished' if finished?
  @env = env.is_a?(Env) ? env : Env.from(env)
  @on_complete_callbacks.each { |callback| callback.call(@env) }
  self
end

def finished?

def finished?
  !!env
end

def headers

def headers
  finished? ? env.response_headers : {}
end

def initialize(env = nil)

def initialize(env = nil)
  @env = Env.from(env) if env
  @on_complete_callbacks = []
end

def marshal_dump

because @on_complete_callbacks cannot be marshalled
def marshal_dump
  finished? ? to_hash : nil
end

def marshal_load(env)

def marshal_load(env)
  @env = Env.from(env)
end

def on_complete(&block)

def on_complete(&block)
  if finished?
    yield(env)
  else
    @on_complete_callbacks << block
  end
  self
end

def reason_phrase

def reason_phrase
  finished? ? env.reason_phrase : nil
end

def status

Experimental RBS support (using type sampling data from the type_fusion project).

def status: () -> untyped

This signature was generated using 1 sample from 1 application.

def status
  finished? ? env.status : nil
end

def success?

def success?
  finished? && env.success?
end

def to_hash

def to_hash
  {
    status: env.status, body: env.body,
    response_headers: env.response_headers,
    url: env.url
  }
end