Skip to main content

Module proxy

Module proxy 

Source
Expand description

Per-request HTTP/1.1 proxy: bridge an inbound capnp-framed stream from the edge to the local TCP listener the caller wants to expose at https://<sub>.trycloudflare.com.

Two code paths share the same entry point:

  • Pooled HTTP/1.1 — for plain requests where both sides advertise Content-Length and no Upgrade / chunked / Connection: close. Acquires a keep-alive socket from crate::pool::Pool, forwards Content-Length-bounded request and response bodies, releases the socket back to the pool. Slashes per-request socket connect cost.

  • Bidi-pump fallback — WebSocket Upgrades (101 Switching Protocols), Transfer-Encoding: chunked, and close-bound responses run two concurrent byte pumps until either half closes. The socket is dropped at the end; no pooling.

Structs§

StreamCounters
Byte counters the supervisor accumulates across all streams.

Constants§

LOCAL_CONNECT_TIMEOUT
How long we wait for the local TCP listener to accept the first byte. Quick tunnels often run alongside a process that just finished booting; 5s gives a generous margin.

Functions§

handle_inbound_stream
Drive one inbound request stream to completion. Reads the ConnectRequest, dispatches by type, writes the ConnectResponse back, pumps the body.