class Faraday::Env

@return [String]
@!attribute reason_phrase
@return [Integer] HTTP response status code
@!attribute status
@return [Hash] HTTP headers from the server
@!attribute response_headers
@return [Response]
@!attribute response
@return [Hash]
@!attribute params
@return [Object] sent if the connection is in parallel mode
@!attribute parallel_manager
@return [Hash] options for configuring SSL requests
@!attribute ssl
@return [Hash] HTTP Headers to be sent to the server.
@!attribute request_headers
- ‘:password` - Proxy server password
- `:user` - Proxy server username
- `:uri` - Proxy Server URI
- `:proxy` - Hash of proxy options
- `:on_data` - Proc for streaming
- `:open_timeout` - read timeout Integer in seconds
- `:timeout` open/read timeout Integer in seconds
Options for configuring the request.
@return [Hash] options for configuring the request.
@!attribute request
@return [URI] URI instance for the current request.
@!attribute url
string.
@return [String] The request body that will eventually be converted to a
@!attribute body
@return [Symbol] HTTP method (`:get`, `:post`)
@!attribute method

def self.from(value)

Returns:
  • (Env) - from given value

Parameters:
  • value (Object) -- a value fitting Option.from(v).
def self.from(value)
  env = super(value)
  if value.respond_to?(:custom_members)
    env.custom_members.update(value.custom_members)
  end
  env
end

def self.member_set

Other tags:
    Private: -
def self.member_set
  @member_set ||= Set.new(members)
end

def [](key)

Parameters:
  • key (Object) --
def [](key)
  return self[current_body] if key == :body
  if in_member_set?(key)
    super(key)
  else
    custom_members[key]
  end
end

def []=(key, value)

Parameters:
  • value (Object) --
  • key (Object) --
def []=(key, value)
  if key == :body
    super(current_body, value)
    return
  end
  if in_member_set?(key)
    super(key, value)
  else
    custom_members[key] = value
  end
end

def body

def body
  self[:body]
end

def body=(value)

def body=(value)
  self[:body] = value
end

def clear_body

Sets content length to zero and the body to the empty string.
def clear_body
  request_headers[ContentLength] = '0'
  self.body = +''
end

def current_body

def current_body
  !!status ? :response_body : :request_body
end

def custom_members

Other tags:
    Private: -
def custom_members
  @custom_members ||= {}
end

def in_member_set?(key)

def in_member_set?(key)
  self.class.member_set.include?(key.to_sym)
end

def in_member_set?(key)

def in_member_set?(key)
  self.class.member_set.include?(key.to_s)
end

def inspect

def inspect
  attrs = [nil]
  members.each do |mem|
    if (value = send(mem))
      attrs << "@#{mem}=#{value.inspect}"
    end
  end
  attrs << "@custom=#{custom_members.inspect}" unless custom_members.empty?
  %(#<#{self.class}#{attrs.join(' ')}>)
end

def needs_body?

Returns:
  • (Boolean) - true if there's no body yet, and the method is in the
def needs_body?
  !body && MethodsWithBodies.include?(method)
end

def parallel?

Returns:
  • (Boolean) - true if there is a parallel_manager
def parallel?
  !!parallel_manager
end

def parse_body?

Returns:
  • (Boolean) - true if the status isn't in the set of
def parse_body?
  !StatusesWithoutBody.include?(status)
end

def stream_response(&block)

def stream_response(&block)
  size = 0
  yielded = false
  block_result = block.call do |chunk| # rubocop:disable Performance/RedundantBlockCall
    if chunk.bytesize.positive? || size.positive?
      yielded = true
      size += chunk.bytesize
      request.on_data.call(chunk, size, self)
    end
  end
  request.on_data.call(+'', 0, self) unless yielded
  block_result
end

def stream_response?

def stream_response?
  request.stream_response?
end

def success?

Returns:
  • (Boolean) - true if status is in the set of {SuccessfulStatuses}.
def success?
  SuccessfulStatuses.include?(status)
end