Class: Faraday::Request

### Home Classes Methods

### In Files

- lib/faraday/request.rb

### Parent

Struct.new(:method, :path, :params, :headers, :body, :options)

### Namespace

- CLASS Faraday::Request::Authorization
- CLASS Faraday::Request::BasicAuthentication
- CLASS Faraday::Request::Multipart
- CLASS Faraday::Request::Retry
- CLASS Faraday::Request::TokenAuthentication
- CLASS Faraday::Request::UrlEncoded

### Methods

- ::create
- #[]
- #[]=
- #headers=
- #params=
- #to_env
- #url

### 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::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::Builder
- Faraday::Builder::Handler
- Faraday::Builder::StackLocked
- Faraday::CompositeReadIO
- Faraday::Connection
- Faraday::Error
- Faraday::Error::ClientError
- Faraday::Error::ConnectionFailed
- Faraday::Error::MissingDependency
- Faraday::Error::ParsingError
- Faraday::Error::ResourceNotFound
- Faraday::Error::TimeoutError
- Faraday::Middleware
- Faraday::MiddlewareRegistry
- Faraday::Request
- Faraday::Request::Authorization
- Faraday::Request::BasicAuthentication
- Faraday::Request::Multipart
- Faraday::Request::Retry
- Faraday::Request::TokenAuthentication
- Faraday::Request::UrlEncoded
- Faraday::Response
- Faraday::Response::Logger
- Faraday::Response::Middleware
- Faraday::Response::RaiseError
- Faraday::Utils
- Faraday::Utils::Headers
- Faraday::Utils::ParamsHash
- Object

No matching classes.

# Faraday::Request

Used to setup urls, params, headers, and the request body in a sane manner.

    @connection.post do |req|
      req.url 'http://localhost', 'a' => '1' # 'http://localhost?a=1'
      req.headers['b'] = '2' # Header
      req.params['c']  = '3' # GET Param
      req['b']         = '2' # also Header
      req.body = 'abc'
    end

### Public Class Methods

create(request_method) click to toggle source

    # File lib/faraday/request.rb, line 33
    def self.create(request_method)
      new(request_method).tap do |request|
        yield request if block_given?
      end
    end

### Public Instance Methods

[](key) click to toggle source

    # File lib/faraday/request.rb, line 67
    def [](key)
      headers[key]
    end

[]=(key, value) click to toggle source

    # File lib/faraday/request.rb, line 71
    def []=(key, value)
      headers[key] = value
    end

headers=(hash) click to toggle source

Public: Replace request headers, preserving the existing hash type

    # File lib/faraday/request.rb, line 47
    def headers=(hash)
      if headers then headers.replace hash
      else super
      end
    end

params=(hash) click to toggle source

Public: Replace params, preserving the existing hash type

    # File lib/faraday/request.rb, line 40
    def params=(hash)
      if params then params.replace hash
      else super
      end
    end

to_env(connection) click to toggle source

ENV Keys :method - a symbolized request method (:get, :post) :body - the request body that will eventually be converted to a string. :url - URI instance for the current request. :status - HTTP response status code :request_headers - hash of HTTP Headers to be sent to the server :response_headers - Hash of HTTP headers from the server :parallel_manager - sent if the connection is in parallel mode :request - Hash of options for configuring the request.

    :timeout      - open/read timeout Integer in seconds
    :open_timeout - read timeout Integer in seconds
    :proxy        - Hash of proxy options
      :uri        - Proxy Server URI
      :user       - Proxy server username
      :password   - Proxy server password

:ssl - Hash of options for configuring SSL requests.

    # File lib/faraday/request.rb, line 91
    def to_env(connection)
      { :method           => method,
        :body             => body,
        :url              => connection.build_exclusive_url(path, params),
        :request_headers  => headers,
        :parallel_manager => connection.parallel_manager,
        :request          => options,
        :ssl              => connection.ssl}
    end

url(path, params = nil) click to toggle source

    # File lib/faraday/request.rb, line 53
    def url(path, params = nil)
      if path.respond_to? :query
        if query = path.query
          path = path.dup
          path.query = nil
        end
      else
        path, query = path.split('?', 2)
      end
      self.path = path
      self.params.merge_query query
      self.params.update(params) if params
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.