Class: Savon::Transport::Faraday

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/savon/transport/faraday.rb

Overview

Faraday-backed HTTP transport for the opt-in Faraday path.

Encapsulates everything Faraday-specific:

* header assembly (SOAP + global + local + cookies + Content-Length)
* request execution via the caller-configured Faraday::Connection

Transport-level concerns (SSL, auth, proxy, timeouts, middleware) are the caller's responsibility via client.faraday before any call is made.

Instance Method Summary collapse

Constructor Details

#initialize(connection, globals) ⇒ Faraday

Returns a new instance of Faraday.

Parameters:

  • connection (Faraday::Connection)

    the memoized connection from client.faraday

  • globals (Savon::GlobalOptions)

    the client-level options



21
22
23
24
# File 'lib/savon/transport/faraday.rb', line 21

def initialize(connection, globals)
  @connection = connection
  @globals    = globals
end

Instance Method Details

#post(url, soap_headers, body, locals) ⇒ Transport::Response

Assembles headers, executes the POST via the Faraday connection, and returns a Transport::Response. Logs the outbound request and inbound response when logging is enabled.

Parameters:

  • url (String)

    the SOAP endpoint URL

  • soap_headers (Hash)

    SOAP-level headers (Content-Type, SOAPAction, etc.)

  • body (String)

    the serialized SOAP envelope

  • locals (Savon::LocalOptions)

    per-request options

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/savon/transport/faraday.rb', line 35

def post(url, soap_headers, body, locals)
  headers = build_headers(soap_headers, body, locals)

  log_request(url, headers, body) if log?

  faraday_response = @connection.post(url, body, headers)
  response = Response.from_faraday(faraday_response)

  log_response(response) if log?

  response
end