class Faraday::Request
@see lib/faraday/request.rb Original class location
Request represents a single HTTP request for a Faraday adapter to make.
def self.create(request_method)
-
(Request)
-
Other tags:
- Yieldparam: request -
Other tags:
- Yield: - for block customization, if block given
Parameters:
-
request_method
(String
) --
def self.create(request_method) new(request_method).tap do |request| yield(request) if block_given? end end
def [](key)
-
(Object)
- value of the given header name
Parameters:
-
key
(Object
) -- key to look up in headers
def [](key) headers[key] end
def []=(key, value)
-
value
(Object
) -- value of header -
key
(Object
) -- key of header to write
def []=(key, value) headers[key] = value end
def headers=(hash)
-
hash
(Hash
) -- new headers
def headers=(hash) if headers headers.replace hash else super end end
def marshal_dump
-
(Hash)
- the hash ready to be serialized in Marshal.
def marshal_dump { method: method, body: body, headers: headers, path: path, params: params, options: options } end
def marshal_load(serialised)
-
serialised
(Hash
) -- the serialised object.
def marshal_load(serialised) self.method = serialised[:method] self.body = serialised[:body] self.headers = serialised[:headers] self.path = serialised[:path] self.params = serialised[:params] self.options = serialised[:options] end
def params=(hash)
-
hash
(Hash
) -- new params
def params=(hash) if params params.replace hash else super end end
def to_env(connection)
-
(Env)
- the Env for this Request
def to_env(connection) Env.new(method, body, connection.build_exclusive_url(path, params), options, headers, connection.ssl, connection.parallel_manager) end
def url(path, params = nil)
-
(void)
-
Parameters:
-
params
(Hash, nil
) -- -
path
(URI, String
) --
def url(path, params = nil) if path.respond_to? :query if (query = path.query) path = path.dup path.query = nil end else anchor_index = path.index('#') path = path.slice(0, anchor_index) unless anchor_index.nil? path, query = path.split('?', 2) end self.path = path self.params.merge_query query, options.params_encoder self.params.update(params) if params end