Class: Savon::Transport::HTTPI
- Inherits:
-
Object
- Object
- Savon::Transport::HTTPI
- Includes:
- Logging
- Defined in:
- lib/savon/transport/httpi.rb
Overview
HTTPI-backed HTTP transport for the default HTTP path.
Encapsulates everything HTTPI-specific:
* header assembly
* proxy/SSL/auth/timeout configuration
* request execution
Instance Method Summary collapse
-
#initialize(globals) ⇒ HTTPI
constructor
A new instance of HTTPI.
-
#normalize_response(httpi_response) ⇒ Transport::Response
Normalizes a native HTTPI::Response into a Transport::Response.
-
#post(url, soap_headers, body, locals) ⇒ Transport::Response
Assembles and executes a SOAP request, returning a Transport::Response.
-
#to_httpi_request(url, soap_headers, body, locals) ⇒ HTTPI::Request
Builds a fully-configured HTTPI::Request.
-
#wsdl_request ⇒ HTTPI::Request
Returns a configured HTTPI::Request for Wasabi's WSDL resolver.
Constructor Details
#initialize(globals) ⇒ HTTPI
Returns a new instance of HTTPI.
19 20 21 |
# File 'lib/savon/transport/httpi.rb', line 19 def initialize(globals) @globals = globals end |
Instance Method Details
#normalize_response(httpi_response) ⇒ Transport::Response
Normalizes a native HTTPI::Response into a Transport::Response.
47 48 49 |
# File 'lib/savon/transport/httpi.rb', line 47 def normalize_response(httpi_response) Response.from_httpi(httpi_response) end |
#post(url, soap_headers, body, locals) ⇒ Transport::Response
Assembles and executes a SOAP request, returning a Transport::Response. Logs the outbound request and inbound response when logging is enabled.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/savon/transport/httpi.rb', line 31 def post(url, soap_headers, body, locals) http_request = to_httpi_request(url, soap_headers, body, locals) log_request(http_request.url, http_request.headers, http_request.body) if log? httpi_response = ::HTTPI.post(http_request, @globals[:adapter]) response = normalize_response(httpi_response) log_response(response) if log? response end |
#to_httpi_request(url, soap_headers, body, locals) ⇒ HTTPI::Request
Builds a fully-configured HTTPI::Request.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/savon/transport/httpi.rb', line 58 def to_httpi_request(url, soap_headers, body, locals) headers = {} headers.merge!(@globals[:headers]) if @globals.include?(:headers) headers.merge!(locals[:headers]) if locals.include?(:headers) # soap_headers are lowest priority soap_headers.each do |k, v| headers[k] ||= v end http_request = ::HTTPI::Request.new http_request.url = url http_request.body = body http_request.headers = headers http_request.(locals[:cookies]) if locals[:cookies] configure_http_request(http_request) http_request end |
#wsdl_request ⇒ HTTPI::Request
Returns a configured HTTPI::Request for Wasabi's WSDL resolver. Applies global headers and all transport-level options and leaves the rest to Wasabi.
80 81 82 83 84 85 |
# File 'lib/savon/transport/httpi.rb', line 80 def wsdl_request http_request = ::HTTPI::Request.new http_request.headers = @globals[:headers].dup if @globals.include?(:headers) configure_http_request(http_request) http_request end |