HttpTransport
HttpTransport: low-level HTTP transport layer.
Sends raw HTTP/1.1 requests over TCP sockets. This is Layer 2 of March's HTTP library — it handles connection management and raw request/response exchange.
Most users should use HttpClient (Layer 3) instead. Use this directly only when you need low-level control over connections.
This module handles plain HTTP only. For HTTPS, use the Tls module (Tls.https_get / Tls.connect). Passing an https:// request to this module returns Err(SchemeNotSupported(...)) rather than silently downgrading to plaintext.
Types
Functions
Open a TCP connection to the request's host:port. Returns Ok(fd) or Err(TransportError).
Refuses https:// requests with `SchemeNotSupported` — use the Tls
module for TLS-enabled connections.Send an HTTP request and receive the response. Opens a TCP connection, sends the request with Connection: close, receives and parses the response, then closes the connection.
Refuses https:// requests with `SchemeNotSupported` — use the Tls
module for TLS-enabled requests.
In js_of_ocaml builds (where `http_fetch_available()` is true) the request
is routed through a synchronous XHR instead, which handles both http and
https; the socket path below is skipped.Send a request and receive the response on an existing fd. Does NOT close the connection — caller manages the fd lifetime. Suitable for keep-alive connection reuse.
Refuses https:// requests with `SchemeNotSupported` even when an fd is
provided, because this module uses plain `tcp_send_all` that would
bypass TLS on a TLS-wrapped fd. Use the Tls module for HTTPS.Convenience wrapper: parse a URL and send a GET request. Returns a TransportError if the URL is invalid or the request fails.
Send a request on an existing fd and stream the response body. Calls on_chunk(chunk_string) for each body chunk as it arrives. Returns Ok((status_code, headers, last_chunk_result)) or Err. Does NOT close the connection.
Refuses https:// requests with `SchemeNotSupported`. Use the Tls
module for streaming over TLS.