Method: Faraday::Connection#run_request

Defined in:
lib/faraday/connection.rb

#run_request(method, url, body, headers) ⇒ Faraday::Response

Builds and runs the Faraday::Request.

Parameters:

  • method (Symbol)

    HTTP method.

  • url (String, URI, nil)

    String or URI to access.

  • body (String, Hash, Array, nil)

    The request body that will eventually be converted to a string; middlewares can be used to support more complex types.

  • headers (Hash, nil)

    unencoded HTTP header key/value pairs.

Returns:



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/faraday/connection.rb', line 439

def run_request(method, url, body, headers)
  unless METHODS.include?(method)
    raise ArgumentError, "unknown http method: #{method}"
  end

  request = build_request(method) do |req|
    req.options.proxy = proxy_for_request(url)
    req.url(url)                if url
    req.headers.update(headers) if headers
    req.body = body             if body
    yield(req) if block_given?
  end

  builder.build_response(self, request)
end