Browse the docs

silk.http.fetch.

Send one HTTP request, follow redirects, decode the content, and deliver the body to a destination that you choose.

When to use#

Use this module when you need more control than silk.http.client: a sink for a large body, a body that you stream, content decoding, a proxy, or a connection pool. Make a Fetch around a FetchClient, such as the Context of silk.http.fetch_native. Then call one function for each request.

Details#

There are three destinations:

  • toSink* gives the body to a Sink in chunks, in order.

  • collect* reads the whole body into memory, up to maxBodyBytes, and returns it only if it is complete.

  • discard* reads and checks the body, and keeps nothing.

The suffix tells what the request body is:

  • Empty: no body.

  • Bytes: a byte slice. It is sent again after a redirect that keeps the body.

  • OneShot: a BodyProducer that can run only one time. A redirect that must send the body again fails with ReplayUnavailable.

  • Replay: a factory that makes a new producer for each attempt.

FetchOptions sets redirects, content decoding, the pool, the proxy, one deadline for the whole operation, and all limits. silk.http.redirect applies the redirect rules, and silk.http.content decodes the content.

Errors#

  • FetchError tells the phase and the reason, with the status and the URI when they are known, and how many body bytes the destination got.

  • RedirectError, ExchangeError, ValueError, and BodyError from the lower modules.

  • DestinationFailure when your Sink fails.

  • OutOfMemoryError if the Allocator fails.

Gotchas#

The deadline is not renewed between redirects or phases. The default FetchOptions do not follow redirects and do not decode content. Set redirect and content to change that.

Import as Fetch with import silk.http.fetch { Fetch }.

Public declarations: 30.

PoolMode#

silk
pub enum PoolMode

Whether a connection can come from a pool.

UseContextPool#

silk
UseContextPool

Use the pool of the client when it has one. Otherwise open a new connection.

Fresh#

silk
Fresh

Always open a new connection, and never put it in a pool.

ProxyMode#

silk
pub enum ProxyMode

Whether the request uses the proxy policy of the client.

InheritContext#

silk
InheritContext

Use the proxy policy of the client. The route is selected again for each redirect.

Direct#

silk
Direct

Connect directly to the origin, without a proxy. Environment variables are not read.

FetchPhase#

silk
pub enum FetchPhase

The phase of a fetch in which an error occurred.

Uri#

silk
Uri

Checking or copying the URI.

Route#

silk
Route

Selecting the route for an origin.

Connect#

silk
Connect

Getting a connection: the pool, name lookup, the connect, or TLS.

Request#

silk
Request

Preparing or sending the request.

Redirect#

silk
Redirect

Applying the redirect rules.

silk
Head

Reading or copying the final response head.

Decode#

silk
Decode

Decoding the content, the framing, or the trailers.

Destination#

silk
Destination

Giving the body to the sink, the collection, or the discard.

Finish#

silk
Finish

Completing the response and deciding if the connection can be used again.

Implementation Debug for FetchPhase#

silk
impl Debug for FetchPhase

Operation debug#

silk
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut Writer

Writes the name of the variant, such as Uri.

FetchLimit#

silk
pub enum FetchLimit

The fetch limit that was exceeded. See FetchReason.LimitExceeded.

EncodedBodyBytes#

silk
EncodedBodyBytes

maxEncodedBodyBytes: the body bytes before decoding.

DeliveredBodyBytes#

silk
DeliveredBodyBytes

maxDeliveredBodyBytes: the body bytes given to the destination.

OwnedMetadataBytes#

silk
OwnedMetadataBytes

maxOwnedMetadataBytes: the copies of the URI, the head, and the trailers.

BufferedBytes#

silk
BufferedBytes

maxBufferedBytes: the read buffer.

CollectionBytes#

silk
CollectionBytes

The maxBodyBytes of a collect* function.

DiscardBytes#

silk
DiscardBytes

The maxDiscardBytes of a discard* function.

Implementation Debug for FetchLimit#

silk
impl Debug for FetchLimit

Operation debug#

silk
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut Writer

Writes the name of the variant, such as EncodedBodyBytes.

FetchContentReason#

silk
pub union FetchContentReason

The reason that content decoding failed. It is a copy of the silk.http.content error that does not borrow the response.

InvalidLimit#

silk
InvalidLimit

A content limit is not valid, or a byte count exceeded it.

Field limit#

silk
pub limit: ContentLimitKind

The limit.

Field allowed#

silk
pub allowed: u64

The value of the limit.

Field attempted#

silk
pub attempted: u64

The value that was found.

CodingSyntax#

silk
CodingSyntax

An item in Content-Encoding is empty or not valid.

Field position#

silk
pub position: CodingPosition

Where the item is.

UnsupportedCoding#

silk
UnsupportedCoding

A content coding has no decoder, for example br.

Field position#

silk
pub position: CodingPosition

Where the coding is.

Field token#

silk
pub token: Bytes

A copy of the coding name.

PartialResponse#

silk
PartialResponse

A 206 partial response has a coding other than identity, which cannot be decoded.

Field position#

silk
pub position: CodingPosition

The first coding that is not identity.

Tunnel#

silk
Tunnel

The response body is a tunnel, not content.

Body#

silk
Body

The body framing failed.

Field error#

silk
pub error: BodyError

The error from silk.http.body.

Buffer#

silk
Buffer

Reading from the transport failed.

Field error#

silk
pub error: BufferError

The error, with its transport cause.

Inflate#

silk
Inflate

Gzip or zlib decoding failed.

Field stage#

silk
pub stage: usize

The decoding stage, from 0, counted from the last coding.

Field wireIndex#

silk
pub wireIndex: usize

The position of the coding in Content-Encoding, from 0.

Field error#

silk
pub error: DecodeError

The error from silk.compress.inflate.

Zstandard#

silk
Zstandard

Zstandard decoding failed.

Field stage#

silk
pub stage: usize

The decoding stage, from 0, counted from the last coding.

Field wireIndex#

silk
pub wireIndex: usize

The position of the coding in Content-Encoding, from 0.

Field error#

silk
pub error: ZstdError

The error from silk.compress.zstd.

TrailingEncodedData#

silk
TrailingEncodedData

There were more bytes after the end of a compressed stream.

Field stage#

silk
pub stage: usize

The decoding stage, from 0, counted from the last coding.

Field wireIndex#

silk
pub wireIndex: usize

The position of the coding in Content-Encoding, from 0.

ArithmeticOverflow#

silk
ArithmeticOverflow

A byte count overflowed.

InvalidState#

silk
InvalidState

The content reader had already failed or stopped.

Implementation Debug for FetchContentReason#

silk
impl Debug for FetchContentReason

Operation debug#

silk
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut Writer

Writes the name of the variant and its fields, such as InvalidLimit { ... }.

FetchContentError#

silk
pub struct FetchContentError

A content decoding error, with byte counts. It owns its data.

Field reason#

silk
pub reason: FetchContentReason

The reason.

Field written#

silk
pub written: usize

The bytes written to the current output chunk.

Field totalEncoded#

silk
pub totalEncoded: u64

The total encoded bytes read.

Field totalIntermediate#

silk
pub totalIntermediate: u64

The total bytes from decoding stages before the last one.

Field totalDecoded#

silk
pub totalDecoded: u64

The total decoded bytes.

Implementation Debug for FetchContentError#

silk
impl Debug for FetchContentError

Operation debug#

silk
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut Writer

Writes the fields, as FetchContentError { reason: ..., written: ..., ... }.

FetchReason#

silk
pub union FetchReason

The reason of a FetchError.

InvalidOptions#

silk
InvalidOptions

The FetchOptions are not valid. See FetchOptions.validate.

InvalidHttpOptions#

silk
InvalidHttpOptions

The client rejected the HTTP limits in the options.

Field error#

silk
pub error: ExchangeError

The error from the client.

HttpValue#

silk
HttpValue

Copying an HTTP value failed.

Field error#

silk
pub error: ValueError

The error from silk.http.message.

HttpBody#

silk
HttpBody

The body or the trailers of the final response are not valid.

Field error#

silk
pub error: BodyError

The error from silk.http.body.

HttpClient#

silk
HttpClient

The exchange failed while the body of the final response was read.

Field error#

silk
pub error: ExchangeError

The error from silk.http.exchange.

SizeOverflow#

silk
SizeOverflow

A byte count overflowed.

DestinationRejected#

silk
DestinationRejected

Your sink rejected a chunk.

Content#

silk
Content

Content decoding failed.

Field error#

silk
pub error: FetchContentError

The content error.

LimitExceeded#

silk
LimitExceeded

A limit in FetchOptions or in the call was exceeded.

Field limit#

silk
pub limit: FetchLimit

The limit.

Field allowed#

silk
pub allowed: u64

The value of the limit.

Field attempted#

silk
pub attempted: u64

The value that was found.

UnsupportedSwitchingResponse#

silk
UnsupportedSwitchingResponse

The final response is 101 Switching Protocols, or a 2xx for CONNECT. Fetch cannot use the connection after such a response.

Field status#

silk
pub status: Status

The status of the response.

Implementation Debug for FetchReason#

silk
impl Debug for FetchReason

Operation debug#

silk
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut Writer

Writes the name of the variant and its fields, such as InvalidOptions.

FetchError#

silk
pub struct FetchError

The error from a fetch, with context. It owns its data.

Details#

It tells the phase and the reason, with the status and the URI when they are known, and how many body bytes the destination got.

Field phase#

silk
pub phase: FetchPhase

The phase in which the error occurred.

Field reason#

silk
pub reason: FetchReason

The reason.

Field status#

silk
pub status: Option<Status>

The status of the final response, when it is known.

Field uri#

silk
pub uri: Option<OwnedUri>

A copy of the current URI, when it is known.

Field deliveredBodyBytes#

silk
pub deliveredBodyBytes: u64

The body bytes that the destination accepted before the error.

Field offeredBodyBytes#

silk
pub offeredBodyBytes: usize

The length of the chunk that the destination rejected, or 0.

Implementation Debug for FetchError#

silk
impl Debug for FetchError

Operation debug#

silk
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut Writer

Writes the fields, as FetchError { phase: ..., reason: ..., ... }.

DestinationFailure#

silk
pub struct DestinationFailure<E>

The error from your Sink, with the context of the fetch.

Field error#

silk
pub error: E

The error from your sink.

Field context#

silk
pub context: FetchError

The context: the phase, the status, the URI, and the bytes delivered before the error.

Implementation Debug for DestinationFailure<E>#

silk
impl<E: Debug> Debug for DestinationFailure<E>

Operation debug#

silk
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut Writer

Writes the fields, as DestinationFailure { error: ..., context: ... }.

RepresentationMetadata#

silk
pub struct RepresentationMetadata

How the content of the response was decoded.

Field applied#

silk
pub applied: AppliedPlan

The decoding plan that was used: raw, or which codings were decoded.

Field completed#

silk
pub completed: bool

true when the framing and all decoding completed.

Field deliveredBytes#

silk
pub deliveredBytes: Option<u64>

The number of body bytes delivered, after completion.

ResponseMetadata#

silk
pub struct ResponseMetadata

The head of the final response, and how its content is decoded. Your sink gets it with each chunk.

Field finalUri#

silk
pub finalUri: OwnedUri

The URI of the final response, after redirects.

Field head#

silk
pub head: OwnedResponseHead

The status, the reason, and the headers of the final response, as received.

Field representation#

silk
pub representation: RepresentationMetadata

How the content is decoded. The headers are not changed by decoding.

Field ownedBytes#

silk
pub ownedBytes: usize

The memory of the URI and head copies, in bytes.

FetchResult#

silk
pub struct FetchResult

The result of a complete response, without the body.

Field metadata#

silk
pub metadata: ResponseMetadata

The final URI and head.

Field trailers#

silk
pub trailers: Option<OwnedTrailers>

The trailers of a chunked response, if any.

Field redirectCount#

silk
pub redirectCount: usize

The number of redirects that were followed.

Field encodedBodyBytes#

silk
pub encodedBodyBytes: u64

The body bytes before decoding.

Field deliveredBodyBytes#

silk
pub deliveredBodyBytes: u64

The body bytes that the destination accepted.

Field ownedMetadataBytes#

silk
pub ownedMetadataBytes: usize

The memory of the URI, head, and trailer copies, in bytes.

CollectedResponse#

silk
pub struct CollectedResponse

The result of a collect* function: the response and its whole body.

Field result#

silk
pub result: FetchResult

The response without the body.

Field body#

silk
pub body: Bytes

The whole body, decoded as selected in the options.

FetchRequest#

silk
pub struct FetchRequest<'uri, 'method, 'headers, 'policy>

The method, URI, headers, and header policy of a request. The body comes from the function that you call.

Implementation FetchRequest<'uri, 'method, 'headers, 'policy>#

silk
impl<'uri, 'method, 'headers, 'policy> FetchRequest<'uri, 'method, 'headers, 'policy>

Associated function make#

silk
pub fn make(
    uri: Uri<'uri>,
    method: Method<'method>,
    headers: Headers<'headers>,
    headerPolicy: HeaderPolicy<'policy>,
    version: Version,
    continuePolicy: ContinuePolicy,
    limits: HeaderLimits,
    maxHeadBytes: usize,
    maxCredentialBytes: usize,
  ) -> Self

Returns a request. continuePolicy selects Expect: 100-continue. The limits apply to the head that is sent. See prepare in silk.http.request.

Associated function get#

silk
pub fn get(uri: Uri<'uri>) -> Self

Returns a GET request for uri, with no headers, the default header policy, and the default limits.

FetchOptions#

silk
pub struct FetchOptions

The settings of a fetch: redirects, content decoding, the pool, the proxy, one deadline for the whole operation, and all limits. Start from FetchOptions.defaults.

Gotchas#

The deadline is not renewed between redirects or phases. The defaults do not follow redirects and do not decode content. Set redirect and content to change that.

Field redirect#

silk
pub redirect: RedirectPolicy

Whether and how to follow redirects. See silk.http.redirect.

Field content#

silk
pub content: ContentMode

Whether to give the body raw or decoded. See silk.http.content.

Field pool#

silk
pub pool: PoolMode

Whether a connection can come from a pool.

Field proxy#

silk
pub proxy: ProxyMode

Whether to use the proxy policy of the client.

Field deadline#

silk
pub deadline: Option<Instant>

One deadline on the MonotonicClock for the whole operation, including all redirects.

Field http#

silk
pub http: ClientLimits

The limits for the HTTP exchange: heads, framing, trailers, and buffers.

Field contentLimits#

silk
pub contentLimits: ContentLimits

The limits for content decoding.

Field maxEncodedBodyBytes#

silk
pub maxEncodedBodyBytes: u64

The maximum body bytes before decoding.

Field maxDeliveredBodyBytes#

silk
pub maxDeliveredBodyBytes: u64

The maximum body bytes that any destination gets.

Field maxOwnedMetadataBytes#

silk
pub maxOwnedMetadataBytes: usize

The maximum memory for the copies of the URI, the head, and the trailers.

Field maxBufferedBytes#

silk
pub maxBufferedBytes: usize

The size of the read buffer for the body. It must not be 0.

Implementation FetchOptions#

silk
impl FetchOptions

Associated function defaults#

silk
pub fn defaults() -> FetchOptions

Returns options that do not follow redirects, do not decode content, use the pool and proxy policy of the client, have no deadline, and allow bodies of 16 MiB.

Method validate#

silk
pub fn validate(self: &Self) -> Result<(), FetchError>

Checks that the options are consistent. It does not allocate or connect. Each fetch function calls it first.

Fetch#

silk
pub struct Fetch<C>

A fetch client around a FetchClient. Make it with Fetch.make, and pass it to the fetch functions.

When to use#

Use it when you need more control than silk.http.client: a sink for a large body, a body that you stream, content decoding, a proxy, or a connection pool. Use the Context of silk.http.fetch_native as the client.

Details#

Each fetch function sends one request, follows redirects, decodes the content, and delivers the body. The prefix of the function name tells the destination: toSink* gives the body to a Sink in chunks, in order; collect* reads the whole body into memory, up to maxBodyBytes, and returns it only if it is complete; discard* reads and checks the body and keeps nothing. The suffix tells the request body: Empty; Bytes, sent again after a redirect that keeps the body; OneShot, a producer that runs one time, so a redirect that must send the body again fails with ReplayUnavailable; or Replay, a factory that makes a new producer for each attempt.

Gotchas#

The deadline is not renewed between redirects or phases. The default FetchOptions do not follow redirects and do not decode content.

Implementation Fetch<C>#

silk
impl<C> Fetch<C>

Associated function make#

silk
pub fn make(client: C) -> Fetch<C>

Returns a fetch client that uses client to get connections.

Sink#

silk
pub interface Sink<E, ?R>

A destination for the body chunks of a toSink* function. The chunks arrive in order. A failure of the sink becomes a DestinationFailure.

Operation write#

silk
effect<'call> fn write<'call>(
    sink: &mut Self,
    metadata: &'call ResponseMetadata,
    chunk: &'call [u8],
    deadline: &'call Option<Instant>,
  ) -> () ! E ? R

Accepts one chunk of the body.

Details#

metadata is the final response head. deadline is the deadline of the whole fetch, or None. The fetch reads no more body until this call returns. The chunk and the metadata are only borrowed for this call.

FetchClient#

silk
pub interface FetchClient<
  'policy,
  RoutedP,
  DirectP,
  A,
  HandlerError,
  AcquisitionError,
  ?HandlerRequirements,
  ?AcquisitionRequirements,
>

Gets a connection and runs one attempt of a request. A fetch calls it again for each redirect.

Details#

An implementation checks the options before it connects, and selects the route for the current URI. With Fresh, it does not use a pool. With Direct, it does not use a proxy policy. deadline is the deadline of the whole fetch.

Operation withAttempt#

silk
effect fn withAttempt(
    client: &mut Self,
    request: AttemptRequest<'policy>,
    httpLimits: ClientLimits,
    poolMode: PoolMode,
    proxyMode: ProxyMode,
    deadline: Option<Instant>,
  ) -> A ! HandlerError | AcquisitionError ? HandlerRequirements | AcquisitionRequirements | &mut HybridAttempt<'policy, RoutedP, DirectP, A, HandlerError ? HandlerRequirements> where
    HandlerRequirements in Without<HandlerRequirements, ByteDuplex>,
    HandlerRequirements in Without<HandlerRequirements, HttpTransport>

Connects and runs one attempt of request with these limits and modes.

toSinkEmpty#

silk
pub effect<'env> fn toSinkEmpty<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  RoutedP,
  DirectP,
  SinkError: Intrinsic.Detached,
  AcquisitionError,
  ?SinkRequirements,
  ?AcquisitionRequirements,
  S: Sink<SinkError ? SinkRequirements> + 'env,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, FetchResult>,
    RedirectError | FetchError | ValueError | BodyError | DestinationFailure<SinkError> | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    SinkRequirements | &mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
  'env,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  options: FetchOptions,
  sink: S,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | DestinationFailure<SinkError> | ExchangeError | OutOfMemoryError | AcquisitionError
? SinkRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  SinkRequirements in Without<SinkRequirements, ByteDuplex>,
  SinkRequirements in Without<SinkRequirements, HttpTransport>,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request with no body, and gives the body of the final response to sink in chunks.

collectEmpty#

silk
pub effect fn collectEmpty<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  RoutedP,
  DirectP,
  AcquisitionError,
  ?AcquisitionRequirements,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, CollectedResponse>,
    RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    &mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  options: FetchOptions,
  maxBodyBytes: usize,
) -> CollectedResponse
! RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError | AcquisitionError
? AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request with no body, and returns the body of the final response in memory. More than maxBodyBytes fails, and no partial body is returned.

discardEmpty#

silk
pub effect fn discardEmpty<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  RoutedP,
  DirectP,
  AcquisitionError,
  ?AcquisitionRequirements,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, FetchResult>,
    RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    &mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  options: FetchOptions,
  maxDiscardBytes: u64,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError | AcquisitionError
? AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request with no body, and reads and checks the body of the final response without keeping it. More than maxDiscardBytes fails.

toSinkBytes#

silk
pub effect<'env> fn toSinkBytes<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  'bytes,
  RoutedP,
  DirectP,
  SinkError: Intrinsic.Detached,
  AcquisitionError,
  ?SinkRequirements,
  ?AcquisitionRequirements,
  S: Sink<SinkError ? SinkRequirements> + 'env,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, FetchResult>,
    RedirectError | FetchError | ValueError | BodyError | DestinationFailure<SinkError> | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    SinkRequirements | &mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
  'env,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  bytes: &'bytes [u8],
  options: FetchOptions,
  sink: S,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | DestinationFailure<SinkError> | ExchangeError | OutOfMemoryError | AcquisitionError
? SinkRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  SinkRequirements in Without<SinkRequirements, ByteDuplex>,
  SinkRequirements in Without<SinkRequirements, HttpTransport>,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request with the body bytes, and gives the body of the final response to sink in chunks.

collectBytes#

silk
pub effect fn collectBytes<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  'bytes,
  RoutedP,
  DirectP,
  AcquisitionError,
  ?AcquisitionRequirements,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, CollectedResponse>,
    RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    &mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  bytes: &'bytes [u8],
  options: FetchOptions,
  maxBodyBytes: usize,
) -> CollectedResponse
! RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError | AcquisitionError
? AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request with the body bytes, and returns the body of the final response in memory. More than maxBodyBytes fails, and no partial body is returned.

discardBytes#

silk
pub effect fn discardBytes<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  'bytes,
  RoutedP,
  DirectP,
  AcquisitionError,
  ?AcquisitionRequirements,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, FetchResult>,
    RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    &mut Redirect.SelectedBody<never, never> | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  bytes: &'bytes [u8],
  options: FetchOptions,
  maxDiscardBytes: u64,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | ExchangeError | OutOfMemoryError | AcquisitionError
? AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request with the body bytes, and reads and checks the body of the final response without keeping it. More than maxDiscardBytes fails.

toSinkOneShot#

silk
pub effect<'env> fn toSinkOneShot<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  RoutedP,
  DirectP,
  ProducerError,
  SinkError: Intrinsic.Detached,
  AcquisitionError,
  ?ProducerRequirements,
  ?SinkRequirements,
  ?AcquisitionRequirements,
  Producer: BodyProducer<ProducerError ? ProducerRequirements> + 'env,
  S: Sink<SinkError ? SinkRequirements> + 'env,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, FetchResult>,
    RedirectError | FetchError | ValueError | BodyError | ProducerError | DestinationFailure<
      SinkError,
    > | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    ProducerRequirements | SinkRequirements | &mut Redirect.SelectedBody<
      ProducerError,
      ProducerRequirements,
    > | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
  'env,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  producer: Producer,
  options: FetchOptions,
  sink: S,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | ProducerError | DestinationFailure<
  SinkError,
> | ExchangeError | OutOfMemoryError | AcquisitionError
? ProducerRequirements | SinkRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
  ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
  SinkRequirements in Without<SinkRequirements, ByteDuplex>,
  SinkRequirements in Without<SinkRequirements, HttpTransport>,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request whose body comes from producer one time, and gives the body of the final response to sink in chunks.

collectOneShot#

silk
pub effect<'env> fn collectOneShot<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  RoutedP,
  DirectP,
  ProducerError,
  AcquisitionError,
  ?ProducerRequirements,
  ?AcquisitionRequirements,
  Producer: BodyProducer<ProducerError ? ProducerRequirements> + 'env,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, CollectedResponse>,
    RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    ProducerRequirements | &mut Redirect.SelectedBody<ProducerError, ProducerRequirements> | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
  'env,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  producer: Producer,
  options: FetchOptions,
  maxBodyBytes: usize,
) -> CollectedResponse
! RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError | AcquisitionError
? ProducerRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
  ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request whose body comes from producer one time, and returns the body of the final response in memory. More than maxBodyBytes fails, and no partial body is returned.

discardOneShot#

silk
pub effect<'env> fn discardOneShot<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  RoutedP,
  DirectP,
  ProducerError,
  AcquisitionError,
  ?ProducerRequirements,
  ?AcquisitionRequirements,
  Producer: BodyProducer<ProducerError ? ProducerRequirements> + 'env,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, FetchResult>,
    RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    ProducerRequirements | &mut Redirect.SelectedBody<ProducerError, ProducerRequirements> | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
  'env,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  producer: Producer,
  options: FetchOptions,
  maxDiscardBytes: u64,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError | AcquisitionError
? ProducerRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
  ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request whose body comes from producer one time, and reads and checks the body of the final response without keeping it. More than maxDiscardBytes fails.

toSinkReplay#

silk
pub effect<'env> fn toSinkReplay<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  RoutedP,
  DirectP,
  FactoryError,
  ProducerError,
  SinkError: Intrinsic.Detached,
  AcquisitionError,
  ?FactoryRequirements,
  ?ProducerRequirements,
  ?SinkRequirements,
  ?AcquisitionRequirements,
  Factory: ReplayFactory<Producer, FactoryError, FactoryRequirements> + 'env,
  Producer: BodyProducer<ProducerError ? ProducerRequirements>,
  S: Sink<SinkError ? SinkRequirements> + 'env,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, FetchResult>,
    RedirectError | FetchError | ValueError | BodyError | ProducerError | DestinationFailure<
      SinkError,
    > | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    ProducerRequirements | SinkRequirements | &mut Redirect.SelectedBody<
      ProducerError,
      ProducerRequirements,
    > | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
  'env,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  factory: Factory,
  options: FetchOptions,
  sink: S,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | FactoryError | ProducerError | DestinationFailure<
  SinkError,
> | ExchangeError | OutOfMemoryError | AcquisitionError
? FactoryRequirements | ProducerRequirements | SinkRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  FactoryRequirements in Without<FactoryRequirements, ByteDuplex>,
  FactoryRequirements in Without<FactoryRequirements, HttpTransport>,
  ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
  ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
  SinkRequirements in Without<SinkRequirements, ByteDuplex>,
  SinkRequirements in Without<SinkRequirements, HttpTransport>,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request whose body comes from a new producer from factory for each attempt, and gives the body of the final response to sink in chunks.

collectReplay#

silk
pub effect<'env> fn collectReplay<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  RoutedP,
  DirectP,
  FactoryError,
  ProducerError,
  AcquisitionError,
  ?FactoryRequirements,
  ?ProducerRequirements,
  ?AcquisitionRequirements,
  Factory: ReplayFactory<Producer, FactoryError, FactoryRequirements> + 'env,
  Producer: BodyProducer<ProducerError ? ProducerRequirements>,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, CollectedResponse>,
    RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    ProducerRequirements | &mut Redirect.SelectedBody<ProducerError, ProducerRequirements> | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
  'env,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  factory: Factory,
  options: FetchOptions,
  maxBodyBytes: usize,
) -> CollectedResponse
! RedirectError | FetchError | ValueError | BodyError | FactoryError | ProducerError | ExchangeError | OutOfMemoryError | AcquisitionError
? FactoryRequirements | ProducerRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  FactoryRequirements in Without<FactoryRequirements, ByteDuplex>,
  FactoryRequirements in Without<FactoryRequirements, HttpTransport>,
  ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
  ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request whose body comes from a new producer from factory for each attempt, and returns the body of the final response in memory. More than maxBodyBytes fails, and no partial body is returned.

discardReplay#

silk
pub effect<'env> fn discardReplay<
  'fetch,
  'uri,
  'method,
  'headers,
  'policy,
  RoutedP,
  DirectP,
  FactoryError,
  ProducerError,
  AcquisitionError,
  ?FactoryRequirements,
  ?ProducerRequirements,
  ?AcquisitionRequirements,
  Factory: ReplayFactory<Producer, FactoryError, FactoryRequirements> + 'env,
  Producer: BodyProducer<ProducerError ? ProducerRequirements>,
  C: FetchClient<
    'policy,
    RoutedP,
    DirectP,
    Redirect.AttemptStep<'policy, FetchResult>,
    RedirectError | FetchError | ValueError | BodyError | ProducerError | ExchangeError | OutOfMemoryError,
    AcquisitionError,
    ProducerRequirements | &mut Redirect.SelectedBody<ProducerError, ProducerRequirements> | &mut MonotonicClock | &mut Allocator | &mut Random,
    AcquisitionRequirements,
  >,
  'env,
>(
  fetch: &'fetch mut Fetch<C>,
  request: FetchRequest<'uri, 'method, 'headers, 'policy>,
  factory: Factory,
  options: FetchOptions,
  maxDiscardBytes: u64,
) -> FetchResult
! RedirectError | FetchError | ValueError | BodyError | FactoryError | ProducerError | ExchangeError | OutOfMemoryError | AcquisitionError
? FactoryRequirements | ProducerRequirements | AcquisitionRequirements | &mut MonotonicClock | &mut Allocator | &mut Random
where
  &mut RoutedP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &HttpTransport from &mut HttpTransport,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut RoutedP provides &ByteDuplex from &mut ByteDuplex,
  &mut DirectP provides &HttpTransport from &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut Random,
  &mut DirectP provides &HttpTransport from &mut HttpTransport,
  FactoryRequirements in Without<FactoryRequirements, ByteDuplex>,
  FactoryRequirements in Without<FactoryRequirements, HttpTransport>,
  ProducerRequirements in Without<ProducerRequirements, ByteDuplex>,
  ProducerRequirements in Without<ProducerRequirements, HttpTransport>,
  AcquisitionRequirements in Without<AcquisitionRequirements, ByteDuplex>,
  AcquisitionRequirements in Without<AcquisitionRequirements, HttpTransport>

Sends a request whose body comes from a new producer from factory for each attempt, and reads and checks the body of the final response without keeping it. More than maxDiscardBytes fails.

Category: HTTP.

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.

View the source of this page