Silk

silk/http_proxy

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.

Bounded HTTP proxy policy, pure route selection, and owned CONNECT rejection metadata.

Details

Proxy policy owns its prepared authentication token and exact-origin bypass entries. Selection does not allocate or use the network. A selected route supplies its configured authentication only through bounded output. CONNECT rejection copies have fixed field and owned-byte limits.

Import as ProxyConfig with import silk.http_proxy { ProxyConfig }.

Public declarations: 15.

ProxyComponent

pub enum ProxyComponent

The proxy value rejected during admission.

ProxyUri

ProxyUri = 0

The proxy URI text.

ProxyEndpoint

ProxyEndpoint = 1

The programmatic proxy endpoint.

Authentication

Authentication = 2

The prepared authentication token.

Bypass

Bypass = 3

The exact-origin bypass policy.

Configuration

Configuration = 4

The complete proxy configuration.

Route

Route = 5

A selected route used by the wrong operation or with a different origin.

ProxyLimit

pub enum ProxyLimit

A bounded proxy configuration resource.

AuthenticationBytes

AuthenticationBytes = 0

The maximum encoded authentication-token byte count.

BypassOrigins

BypassOrigins = 1

The maximum exact-origin bypass-entry count.

OwnedConfigurationBytes

OwnedConfigurationBytes = 2

The maximum total owned configuration byte count.

ProxyReason

pub union ProxyReason

The reason proxy policy admission failed.

InvalidProxyUri

ProxyReason.InvalidProxyUri: ProxyReason

The proxy URI has invalid syntax or a prohibited URI component.

InvalidProxyPort

ProxyReason.InvalidProxyPort: ProxyReason

The programmatic proxy endpoint has port zero.

InvalidAuthentication

ProxyReason.InvalidAuthentication: ProxyReason

The prepared Basic token is empty or is not canonical strict Base64.

SizeOverflow

ProxyReason.SizeOverflow: ProxyReason

The required owned byte count does not fit in usize.

LimitExceeded

ProxyReason.LimitExceeded { limit: ProxyLimit, allowed: usize, attempted: usize }: ProxyReason

A resource exceeds its admitted maximum.

Field limit

pub limit: ProxyLimit

The resource that exceeds its limit.

Field allowed

pub allowed: usize

The inclusive admitted maximum.

Field attempted

pub attempted: usize

The rejected resource value.

UnsupportedProxyTransport

ProxyReason.UnsupportedProxyTransport: ProxyReason

The proxy URI uses the unsupported https scheme.

InvalidRoute

ProxyReason.InvalidRoute: ProxyReason

The selected route mode or original origin is incompatible with the requested operation.

ProxyAdmissionError

pub struct ProxyAdmissionError

A copyable proxy-policy admission failure containing no identity or credential bytes.

Field component

pub component: ProxyComponent

The proxy value that failed admission.

Field reason

pub reason: ProxyReason

The admission rule that failed.

ProxyError

pub union ProxyError

A typed proxy failure whose response variants own only bounded, nonsecret metadata.

Admission

ProxyError.Admission { error: ProxyAdmissionError }: ProxyError

Configuration, route, or credential admission failed without retaining input bytes.

Field error

pub error: ProxyAdmissionError

The structured copyable admission failure.

ProxyMetadataLimit

ProxyError.ProxyMetadataLimit: ProxyError

A complete CONNECT response exceeded the fixed owned-metadata budget.

ProxyAuthenticationRequired

ProxyError.ProxyAuthenticationRequired { response: OwnedResponseHead }: ProxyError

A 407 response retaining status, reason, and ordered Proxy-Authenticate fields only.

Field response

pub response: OwnedResponseHead

The bounded independently owned response metadata.

ProxyRejected

ProxyError.ProxyRejected { response: OwnedResponseHead }: ProxyError

Another final non-2xx response retaining status, reason, and all ordered fields.

Field response

pub response: OwnedResponseHead

The bounded independently owned response metadata.

InvalidConnectResponse

ProxyError.InvalidConnectResponse: ProxyError

Response classification was attempted before a final CONNECT response existed.

Associated function ProxyError.invalidRoute

pub fn invalidRoute() -> ProxyError

Returns the credential-free failure for an incompatible sealed route.

ProxyConfigId

pub struct ProxyConfigId

An opaque configuration identity made from a caller-supplied nonsecret u64.

Associated function ProxyConfigId.make

pub fn make(value: u64) -> ProxyConfigId

Preserves a caller-supplied nonsecret identity payload opaquely.

Method ProxyConfigId.equals

pub fn equals<'life0, 'life1>(self: &'life0 ProxyConfigId, other: &'life1 ProxyConfigId) -> bool

Reports exact caller-payload equality without exposing the payload.

ProxyAuthContextId

pub struct ProxyAuthContextId

An opaque authentication-context identity made from a caller-supplied nonsecret u64.

Associated function ProxyAuthContextId.make

pub fn make(value: u64) -> ProxyAuthContextId

Preserves a caller-supplied nonsecret identity payload opaquely.

Method ProxyAuthContextId.equals

pub fn equals<'life0, 'life1>(self: &'life0 ProxyAuthContextId, other: &'life1 ProxyAuthContextId) -> bool

Reports exact caller-payload equality without exposing the payload.

ProxyAuth

pub union ProxyAuth

Prepared proxy authentication owned by a proxy configuration.

None

ProxyAuth.None { contextIdValue: ProxyAuthContextId }: ProxyAuth

An authentication context that has no credential token.

Basic

ProxyAuth.Basic { contextIdValue: ProxyAuthContextId, tokenValue: Bytes }: ProxyAuth

An authentication context that owns a prepared Basic token.

Associated function ProxyAuth.none

pub fn none(contextId: ProxyAuthContextId) -> ProxyAuth

Creates an authentication context with no credential bytes.

Associated function ProxyAuth.preparedBasic

pub effect<'life0> fn preparedBasic<'life0>(contextId: ProxyAuthContextId, token: &'life0 [u8]) -> silk/result.Result<silk/http_proxy.ProxyAuth, silk/http_proxy.ProxyError> ! OutOfMemoryError ? &mut Allocator

Strictly validates and copies one nonempty prepared Basic token.

Method ProxyAuth.contextId

pub fn contextId<'life0>(self: &'life0 ProxyAuth) -> ProxyAuthContextId

Returns the caller-supplied authentication-context identity.

Method ProxyAuth.ownedBytes

pub fn ownedBytes<'life0>(self: &'life0 ProxyAuth) -> usize

Returns retained credential bytes without exposing them.

BypassPolicy

pub struct BypassPolicy

A bounded list of exact normalized origins that bypass the proxy.

Associated function BypassPolicy.copy

pub effect<'life0> fn copy<'life0>(origins: &'life0 [silk/http_origin.Origin]) -> silk/result.Result<silk/http_proxy.BypassPolicy, silk/http_proxy.ProxyError> ! OutOfMemoryError ? &mut Allocator

Copies at most 64 exact normalized HTTP origins into immutable owned policy.

Method BypassPolicy.contains

pub fn contains<'life0, 'life1>(self: &'life0 BypassPolicy, origin: &'life1 silk/http_origin.Origin) -> bool

Reports exact scheme, normalized-host, and effective-port membership.

Method BypassPolicy.ownedBytes

pub fn ownedBytes<'life0>(self: &'life0 BypassPolicy) -> usize

Returns copied bypass-entry storage size.

ProxyConfig

pub struct ProxyConfig

Immutable owned proxy configuration.

Associated function ProxyConfig.make

pub fn make(id: ProxyConfigId, proxyHost: Host, proxyPort: Port, authentication: ProxyAuth, bypass: BypassPolicy, maxOwnedConfigBytes: usize) -> silk/result.Result<silk/http_proxy.ProxyConfig, silk/http_proxy.ProxyError>

Admits a plain programmatic proxy endpoint under a total owned-byte budget.

Associated function ProxyConfig.fromUri

pub fn fromUri<'text>(id: ProxyConfigId, text: string<'text>, authentication: ProxyAuth, bypass: BypassPolicy, maxOwnedConfigBytes: usize) -> silk/result.Result<silk/http_proxy.ProxyConfig, silk/http_proxy.ProxyError>

Parses only a plain http authority with no userinfo, path, query, or fragment.

Method ProxyConfig.id

pub fn id<'life0>(self: &'life0 ProxyConfig) -> ProxyConfigId

Returns the caller-supplied configuration identity.

Method ProxyConfig.authContextId

pub fn authContextId<'life0>(self: &'life0 ProxyConfig) -> ProxyAuthContextId

Returns the caller-supplied authentication-context identity.

Method ProxyConfig.proxyHost

pub fn proxyHost<'life0>(self: &'life0 ProxyConfig) -> Host

Returns the checked proxy host.

Method ProxyConfig.proxyPort

pub fn proxyPort<'life0>(self: &'life0 ProxyConfig) -> Port

Returns the checked nonzero proxy port.

Method ProxyConfig.ownedBytes

pub fn ownedBytes<'life0>(self: &'life0 ProxyConfig) -> usize

Returns the copied host, token, and bypass-entry byte count.

RouteMode

pub enum RouteMode

The route mode selected for one origin.

Direct

Direct = 0

Contact the origin directly.

Forward

Forward = 1

Contact the proxy and use an absolute-form HTTP request.

Tunnel

Tunnel = 2

Contact the proxy and use CONNECT before origin TLS.

Route

pub union Route<'configuration>

The pure route selected for one original HTTP origin.

Direct

Route<'configuration>.Direct { identity: RouteIdentity, configuration: &'configuration silk/http_proxy.ProxyConfig, origin: Origin }: Route<'configuration>

A route that contacts an exact bypass origin directly.

Field origin

pub origin: Origin

The original origin that matched bypass policy.

Forward

Route<'configuration>.Forward { identity: RouteIdentity, configuration: &'configuration silk/http_proxy.ProxyConfig, origin: Origin }: Route<'configuration>

A route that sends plaintext HTTP through the proxy.

Field origin

pub origin: Origin

The original plaintext HTTP origin.

Tunnel

Route<'configuration>.Tunnel { identity: RouteIdentity, configuration: &'configuration silk/http_proxy.ProxyConfig, origin: Origin }: Route<'configuration>

A route that establishes a proxy tunnel for origin TLS.

Field origin

pub origin: Origin

The original HTTPS origin for TLS authentication.

Method Route.mode

pub fn mode<'configuration, 'life1>(self: &'life1 Route<'configuration>) -> RouteMode

Returns the selected route mode.

Method Route.originalOrigin

pub fn originalOrigin<'configuration, 'life1>(self: &'life1 Route<'configuration>) -> Origin

Returns the original origin that policy evaluated.

Method Route.proxyHost

pub fn proxyHost<'configuration, 'life1>(self: &'life1 Route<'configuration>) -> Host

Returns the proxy host retained when policy selected the route.

Method Route.proxyPort

pub fn proxyPort<'configuration, 'life1>(self: &'life1 Route<'configuration>) -> Port

Returns the proxy port retained when policy selected the route.

Method Route.physicalPeer

pub fn physicalPeer<'configuration, 'life1>(self: &'life1 Route<'configuration>) -> silk/result.Result<silk/http_origin.Origin, silk/http_origin.OriginError>

Returns the plaintext proxy peer retained by the sealed route.

Method Route.proxyAuthorizationLength

pub fn proxyAuthorizationLength<'configuration, 'life1>(self: &'life1 Route<'configuration>) -> usize

Returns the complete configured Proxy-Authorization value length, or zero when absent.

Details

The prepared token remains private; possessing a policy-selected route is the capability to request its bounded wire representation.

Method Route.writeProxyAuthorizationInto

pub fn writeProxyAuthorizationInto<'configuration, 'life1, 'life2>(self: &'life1 Route<'configuration>, output: &'life2 mut [u8]) -> silk/option.Option<usize>

Writes the complete configured Proxy-Authorization value without exposing token storage. Returns None without changing output when it is too small.

Method Route.configId

pub fn configId<'configuration, 'life1>(self: &'life1 Route<'configuration>) -> ProxyConfigId

Returns the configuration identity retained when policy selected the route.

Method Route.authContextId

pub fn authContextId<'configuration, 'life1>(self: &'life1 Route<'configuration>) -> ProxyAuthContextId

Returns the authentication-context identity retained when policy selected the route.

Method Route.key

pub fn key<'configuration, 'life1>(self: &'life1 Route<'configuration>) -> RouteKey

Returns a stable key without reading or formatting authentication bytes.

Method Route.recompute

pub fn recompute<'configuration, 'life1>(self: &'life1 Route<'configuration>, origin: Origin) -> silk/http_proxy.Route<'configuration>

Recomputes policy for a new origin under the current immutable configuration.

RouteKey

pub struct RouteKey

Stable route identity for later pooling and redirect recomputation.

Method RouteKey.originalOrigin

pub fn originalOrigin<'life0>(self: &'life0 RouteKey) -> Origin

Returns the normalized original origin retained by this sealed route identity.

Method RouteKey.mode

pub fn mode<'life0>(self: &'life0 RouteKey) -> RouteMode

Returns the selected route mode without exposing proxy configuration or credential bytes.

Method RouteKey.equals

pub fn equals<'life0, 'life1>(self: &'life0 RouteKey, other: &'life1 RouteKey) -> bool

Compares route mode, original origin, proxy endpoint, and both opaque identities.

Implementation Copy for ProxyReason

impl Copy for ProxyReason

Implementation Copy for ProxyAdmissionError

impl Copy for ProxyAdmissionError

Implementation Copy for ProxyConfigId

impl Copy for ProxyConfigId

Implementation Copy for ProxyAuthContextId

impl Copy for ProxyAuthContextId

Implementation Copy for silk/http_proxy.Route<'configuration>

impl Copy for silk/http_proxy.Route<'configuration>

Implementation Copy for RouteKey

impl Copy for RouteKey

selectRoute

pub fn selectRoute<'configuration>(configuration: &'configuration silk/http_proxy.ProxyConfig, origin: Origin) -> silk/http_proxy.Route<'configuration>

Purely selects Direct, Forward, or Tunnel for one original origin.

classifyConnect

pub effect<'env> fn classifyConnect<'life0: 'env, 'life1: 'env, 'env>(head: &'life0 silk/http_head.ResponseHead<'life1>) -> () ! ProxyError | OutOfMemoryError ? &mut Allocator

Classifies a complete final CONNECT response into success or bounded rejection metadata.

Details

Any 2xx response is accepted. A 407 retains status, reason, and ordered duplicate Proxy-Authenticate fields only; other final non-2xx responses retain all ordered fields. Complete-head copy failures map to ProxyMetadataLimit, while allocation failure remains OutOfMemoryError. Call this only after the shared client's parser has returned a final head.

On this page

DetailsProxyComponentProxyUriProxyEndpointAuthenticationBypassConfigurationRouteProxyLimitAuthenticationBytesBypassOriginsOwnedConfigurationBytesProxyReasonInvalidProxyUriInvalidProxyPortInvalidAuthenticationSizeOverflowLimitExceededField limitField allowedField attemptedUnsupportedProxyTransportInvalidRouteProxyAdmissionErrorField componentField reasonProxyErrorAdmissionField errorProxyMetadataLimitProxyAuthenticationRequiredField responseProxyRejectedField responseInvalidConnectResponseAssociated function ProxyError.invalidRouteProxyConfigIdAssociated function ProxyConfigId.makeMethod ProxyConfigId.equalsProxyAuthContextIdAssociated function ProxyAuthContextId.makeMethod ProxyAuthContextId.equalsProxyAuthNoneBasicAssociated function ProxyAuth.noneAssociated function ProxyAuth.preparedBasicMethod ProxyAuth.contextIdMethod ProxyAuth.ownedBytesBypassPolicyAssociated function BypassPolicy.copyMethod BypassPolicy.containsMethod BypassPolicy.ownedBytesProxyConfigAssociated function ProxyConfig.makeAssociated function ProxyConfig.fromUriMethod ProxyConfig.idMethod ProxyConfig.authContextIdMethod ProxyConfig.proxyHostMethod ProxyConfig.proxyPortMethod ProxyConfig.ownedBytesRouteModeDirectForwardTunnelRouteDirectField originForwardField originTunnelField originMethod Route.modeMethod Route.originalOriginMethod Route.proxyHostMethod Route.proxyPortMethod Route.physicalPeerMethod Route.proxyAuthorizationLengthDetailsMethod Route.writeProxyAuthorizationIntoMethod Route.configIdMethod Route.authContextIdMethod Route.keyMethod Route.recomputeRouteKeyMethod RouteKey.originalOriginMethod RouteKey.modeMethod RouteKey.equalsImplementation Copy for ProxyReasonImplementation Copy for ProxyAdmissionErrorImplementation Copy for ProxyConfigIdImplementation Copy for ProxyAuthContextIdImplementation Copy for silk/http_proxy.Route<'configuration>Implementation Copy for RouteKeyselectRouteclassifyConnectDetails