silk/http_request
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc.
Origin-bound HTTP request preparation with finite storage and explicit header policy.
Details
prepare owns the direct serialized head before an exchange can send bytes. The routed
operations require a policy-selected proxy route. They derive the proxy peer and authentication
from that route. All operations generate framing fields and reject conflicting caller fields.
Import as HttpRequest with import silk.http_request as HttpRequest.
Public declarations: 11.
BodyMode
pub union BodyModeThe exact request payload delimiter.
Empty
BodyMode.Empty: BodyModeSends no request payload.
KnownLength
BodyMode.KnownLength { length: u64 }: BodyModeSends exactly this many payload bytes.
Field length
pub length: u64The exact payload length.
Chunked
BodyMode.Chunked: BodyModeSends HTTP/1.1 chunks and explicit trailers.
Implementation Copy for BodyMode
impl Copy for BodyModeHeaderControl
pub union HeaderControl<'value>A generated field policy that distinguishes omission from a default.
Default
HeaderControl<'value>.Default: HeaderControl<'value>Generates the documented default value.
Omit
HeaderControl<'value>.Omit: HeaderControl<'value>Deliberately omits the field when the protocol permits it.
Value
HeaderControl<'value>.Value { value: &'value [u8] }: HeaderControl<'value>Uses one explicit validated value.
Field value
pub value: &'value [u8]The caller-owned semantic field bytes.
Implementation Copy for silk/http_request.HeaderControl<'value>
impl Copy for silk/http_request.HeaderControl<'value>Authorization
pub union Authorization<'value>One explicit authorization source.
Absent
Authorization<'value>.Absent: Authorization<'value>Sends no generated authorization field.
Value
Authorization<'value>.Value { value: &'value [u8] }: Authorization<'value>Sends one explicit validated field value.
Field value
pub value: &'value [u8]The complete authorization field value.
Basic
Authorization<'value>.Basic { username: &'value [u8], password: &'value [u8] }: Authorization<'value>Encodes caller-selected username and password bytes.
Field username
pub username: &'value [u8]Username bytes without colon or controls.
Field password
pub password: &'value [u8]Password bytes without controls.
Implementation Copy for silk/http_request.Authorization<'value>
impl Copy for silk/http_request.Authorization<'value>BasicSecurity
pub enum BasicSecurityExplicit permission to send Basic credentials without TLS.
RequireTls
RequireTls = 0Rejects Basic credentials for a plaintext origin.
AllowInsecureBasic
AllowInsecureBasic = 1Permits plaintext Basic without changing HTTPS authentication.
HeaderPolicy
pub struct HeaderPolicy<'value>Policy for generated request fields and connection persistence.
Field host
pub host: silk/http_request.HeaderControl<'value>Defaults to the normalized origin authority; HTTP/1.1 cannot omit it.
Field userAgent
pub userAgent: silk/http_request.HeaderControl<'value>Defaults to silk-http/1.
Field accept
pub accept: silk/http_request.HeaderControl<'value>Defaults to */*.
Field authorization
pub authorization: silk/http_request.Authorization<'value>One optional explicit authorization source.
Field basicSecurity
pub basicSecurity: BasicSecurityRequires TLS for Basic unless explicitly overridden.
Field http10KeepAlive
pub http10KeepAlive: boolPermits HTTP/1.0 keep-alive; HTTP/1.1 uses normal persistence.
Associated function HeaderPolicy.defaults
pub fn defaults<'value>() -> silk/http_request.HeaderPolicy<'value>Returns generated defaults, absent authorization, and plaintext Basic rejection.
Implementation Copy for silk/http_request.HeaderPolicy<'value>
impl Copy for silk/http_request.HeaderPolicy<'value>RequestError
pub union RequestErrorA precise preflight failure with no network side effects.
Value
RequestError.Value { error: ValueError }: RequestErrorA shared HTTP value failed validation.
Field error
pub error: ValueErrorThe original value failure.
Origin
RequestError.Origin { error: OriginError }: RequestErrorAn origin could not be constructed or serialized.
Field error
pub error: OriginErrorThe original origin failure.
Basic
RequestError.Basic { error: BasicError }: RequestErrorCredentials failed strict Basic encoding.
Field error
pub error: BasicErrorThe credential failure, without credential bytes.
ConflictingHeader
RequestError.ConflictingHeader: RequestErrorA caller field conflicts with generated policy.
ConflictingAuthority
RequestError.ConflictingAuthority: RequestErrorThe explicit Host differs from the connection origin.
MissingHost
RequestError.MissingHost: RequestErrorHTTP/1.1 cannot omit Host.
InvalidBodyMode
RequestError.InvalidBodyMode: RequestErrorThe body or continue mode is unavailable for the selected version.
MultipleAuthorization
RequestError.MultipleAuthorization: RequestErrorMore than one authorization source was supplied.
InsecureBasic
RequestError.InsecureBasic: RequestErrorPlaintext Basic lacks explicit permission.
ProxyAuthorization
RequestError.ProxyAuthorization: RequestErrorA direct request supplies proxy credentials.
CredentialLimit
RequestError.CredentialLimit: RequestErrorCredential bytes exceed the finite budget.
HeaderLimit
RequestError.HeaderLimit: RequestErrorGenerated or copied fields exceed the configured finite count.
InvalidTarget
RequestError.InvalidTarget: RequestErrorA direct request uses an absolute target for another origin.
PreparedRequest
pub struct PreparedRequestOne owned, origin-bound, preflighted head with unforgeable framing policy.
Method PreparedRequest.bytes
pub fn bytes<'a>(self: &'a PreparedRequest) -> &'a [u8]Borrows the serialized request head until this owner is dropped.
Method PreparedRequest.origin
pub fn origin<'life0>(self: &'life0 PreparedRequest) -> OriginReturns the logical request origin used for target, Host, and origin credentials.
Method PreparedRequest.physicalPeer
pub fn physicalPeer<'life0>(self: &'life0 PreparedRequest) -> OriginReturns the physical peer on whose connection this request is admitted.
Method PreparedRequest.version
pub fn version<'life0>(self: &'life0 PreparedRequest) -> VersionReturns the admitted HTTP version.
Method PreparedRequest.bodyMode
pub fn bodyMode<'life0>(self: &'life0 PreparedRequest) -> BodyModeReturns the exact selected body delimiter.
Method PreparedRequest.require100
pub fn require100<'life0>(self: &'life0 PreparedRequest) -> boolReturns whether the head contains the generated 100-continue expectation.
prepare
pub effect<'env> fn prepare<'value: 'env, 'life1: 'env, 'life2: 'env, 'life3: 'env, 'env>(origin: &'life1 silk/http_origin.Origin, version: Version, method: silk/http.Method<'value>, target: silk/http_target.RequestTarget<'value>, headers: &'life2 silk/http_headers.Headers<'value>, policy: &'life3 silk/http_request.HeaderPolicy<'value>, body: BodyMode, require100: bool, limits: Limits, maxHeadBytes: usize, maxCredentialBytes: usize) -> PreparedRequest ! RequestError | OutOfMemoryError ? &mut AllocatorValidates and serializes one request before any transport operation.
Details
Caller fields preserve order. Host, User-Agent, Accept, framing, Expect, and Connection belong
to policy and cannot also occur in headers. Output owns all borrowed input bytes.
maxHeadBytes and maxCredentialBytes bound owned head and credential storage.
prepareForward
pub effect<'env> fn prepareForward<'configuration: 'env, 'value: 'env, 'life2: 'env, 'life3: 'env, 'life4: 'env, 'life5: 'env, 'env>(route: &'life2 silk/http_proxy.Route<'configuration>, uri: &'life3 silk/uri.Uri<'value>, version: Version, method: silk/http.Method<'value>, headers: &'life4 silk/http_headers.Headers<'value>, policy: &'life5 silk/http_request.HeaderPolicy<'value>, body: BodyMode, require100: bool, limits: Limits, maxHeadBytes: usize, maxCredentialBytes: usize) -> PreparedRequest ! ProxyError | RequestError | OutOfMemoryError ? &mut AllocatorPrepares one Forward route as an origin-bound absolute-form request for its plain proxy peer.
Details
The sealed route is the only source of the physical peer and Proxy-Authorization. The
original URI spelling is preserved except that user information and fragments are excluded and
an empty path becomes /. Forward preparation always generates the logical-origin Host,
including for HTTP/1.0.
prepareConnect
pub effect<'env> fn prepareConnect<'configuration: 'env, 'life1: 'env, 'env>(route: &'life1 silk/http_proxy.Route<'configuration>, limits: Limits, maxHeadBytes: usize, maxCredentialBytes: usize) -> PreparedRequest ! ProxyError | RequestError | OutOfMemoryError ? &mut AllocatorPrepares the one body-free HTTP/1.1 CONNECT head admitted by a Tunnel route.
Details
The authority-form target and Host are both derived from the route's normalized original origin and always include its effective port. Callers cannot supply fields, a body, a physical peer, or proxy credentials.
fromUri
pub effect<'env> fn fromUri<'value: 'env, 'life1: 'env, 'life2: 'env, 'life3: 'env, 'env>(uri: &'life1 silk/uri.Uri<'value>, version: Version, method: silk/http.Method<'value>, headers: &'life2 silk/http_headers.Headers<'value>, policy: &'life3 silk/http_request.HeaderPolicy<'value>, body: BodyMode, require100: bool, limits: Limits, maxHeadBytes: usize, maxCredentialBytes: usize) -> PreparedRequest ! RequestError | OutOfMemoryError ? &mut AllocatorConverts a validated URI to an origin-form request with query and no fragment.