Lather.Http.Transport (lather v1.0.42)

View Source

HTTP transport layer for SOAP requests.

Handles HTTP/HTTPS communication using Finch for connection pooling and efficient request handling.

Summary

Functions

Builds HTTP headers for SOAP requests.

Sends a POST request with the SOAP envelope to the specified endpoint.

Creates SSL options for secure SOAP connections.

Validates a URL for SOAP requests.

Functions

build_headers(options)

@spec build_headers(keyword()) :: [{String.t(), String.t()}]

Builds HTTP headers for SOAP requests.

Parameters

  • options - Request options including SOAP version and action

Options

  • :soap_version - SOAP protocol version (:v1_1 or :v1_2, default: :v1_1)
  • :soap_action - SOAPAction header value or action to embed in Content-Type
  • :headers - Additional custom headers
  • :basic_auth - Basic authentication credentials

post(url, body, options \\ [])

@spec post(String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, any()}

Sends a POST request with the SOAP envelope to the specified endpoint.

Parameters

  • url - The SOAP endpoint URL
  • body - The SOAP envelope XML as a string
  • options - Request options

Options

  • :timeout - Request timeout in milliseconds
  • :headers - Additional headers to include
  • :soap_action - SOAPAction header value
  • :soap_version - SOAP protocol version (:v1_1 or :v1_2, default: :v1_1)
  • :ssl_options - SSL/TLS options for HTTPS connections
  • :pool_timeout - Connection pool timeout in milliseconds
  • :basic_auth - Basic authentication credentials {username, password}

Examples

# Example usage (would make actual HTTP request):
# Transport.post("https://example.com/soap", "<soap>...</soap>", [])
# {:ok, %{status: 200, body: "<response>...</response>"}}

# With Basic authentication:
# Transport.post(url, body, basic_auth: {"user", "pass"})

ssl_options(options \\ [])

@spec ssl_options(keyword()) :: keyword()

Creates SSL options for secure SOAP connections.

Parameters

  • options - SSL configuration options

Options

  • :verify - Verification mode (:verify_peer or :verify_none)
  • :cacerts - List of CA certificates
  • :cert - Client certificate
  • :key - Client private key
  • :versions - Supported TLS versions

validate_url(url)

@spec validate_url(String.t()) :: :ok | {:error, :invalid_url}

Validates a URL for SOAP requests.

Examples

iex> Lather.Http.Transport.validate_url("https://example.com/soap")
:ok

iex> Lather.Http.Transport.validate_url("invalid-url")
{:error, :invalid_url}