class Faraday::Request
end
req.body = ‘abc’<br>req = ‘2’ # also Header<br>req.params = ‘3’ # GET Param<br>req.headers = ‘2’ # Header
req.url ‘localhost’, ‘a’ => ‘1’ # ‘localhost?a=1’
@connection.post do |req|
Used to setup urls, params, headers, and the request body in a sane manner.
def self.create(request_method)
def self.create(request_method) new(request_method).tap do |request| yield request if block_given? end end
def [](key)
def [](key) headers[key] end
def []=(key, value)
def []=(key, value) headers[key] = value end
def initialize(request_method)
def initialize(request_method) @method = request_method self.params = {} self.headers = {} self.options = {} end
def to_env(connection)
:password - Proxy server password
:user - Proxy server username
:uri - Proxy Server URI
:proxy - Hash of proxy options
:open_timeout - read timeout Integer in seconds
:timeout - open/read timeout Integer in seconds
:request - Hash of options for configuring the request.
:parallel_manager - sent if the connection is in parallel mode
:response_headers - Hash of HTTP headers from the server
:request_headers - hash of HTTP Headers to be sent to the server
:status - HTTP response status code
:url - Addressable::URI instance of the URI for the current request.
:body - the request body that will eventually be converted to a string.
:method - a symbolized request method (:get, :post)
ENV Keys
def to_env(connection) env_params = connection.params.merge(params) env_headers = connection.headers.merge(headers) request_options = Utils.deep_merge(connection.options, options) Utils.deep_merge!(request_options, :proxy => connection.proxy) { :method => method, :body => body, :url => connection.build_url(path, env_params), :request_headers => env_headers, :parallel_manager => connection.parallel_manager, :request => request_options, :ssl => connection.ssl} end
def url(path, params = {})
def url(path, params = {}) self.path = path self.params = params end