Skip to main content

encode_request_target

Function encode_request_target 

pub fn encode_request_target(
    method: &Method,
    uri: &Uri,
    extensions: &Extensions,
    output: &mut Vec<u8>,
) -> Result<(), HeadError>
Available on crate features http and std only.
Expand description

Encode the HTTP/1 request-target selected by Rama connection metadata.

Direct requests use origin-form, CONNECT uses authority-form, OPTIONS * uses asterisk-form, and insecure requests on an established HTTP forward proxy connection use absolute-form, with the resolved protocol as scheme for a URI without one; a URI with neither a scheme nor an authority cannot name its origin there and is sent as it would be directly (origin-form, or * for a server-wide OPTIONS), leaving the origin to the Host header. Fragments are never emitted, nor is userinfo for HTTP-family schemes (see Uri::write_http_absolute_form), and a rootless path is sent rooted. Route intent is deliberately ignored: the established connection route is the only authoritative signal after fallback and pool selection. When an Egress connection snapshot is present, its route (including absence) takes precedence over request-local metadata. Low-level callers without a connection snapshot must insert EstablishedProxyRoute::Forward themselves.

On error nothing is written to output.