pub struct HeaderSource(/* private fields */);Expand description
Where a Rust host transport reads its request headers (auth, actor and
project ids, per-round trace headers). The transport calls it before every
host-authenticated HTTP request and every realtime handshake; a signed URL
never carries them. It receives the request’s HeaderContext and None
for an ordinary read, or the headers the server just answered 401 to for a
refresh. A source that answers None has no headers to give, and the
request fails with the retryable sync.auth_required
(causeKind: "header_source") before any network I/O.
Concurrent reads of one client and round share one in-flight call, with the first reader’s context. Ordinary reads and refreshes fly separately, so a refresh never joins an ordinary read of the refused headers, and different rounds or clients never share a call. Clones share the flights.
Implementations§
Source§impl HeaderSource
impl HeaderSource
pub fn new( read: impl Fn(&HeaderContext, Option<&[(String, String)]>) -> Option<Vec<(String, String)>> + Send + Sync + 'static, ) -> Self
Sourcepub fn read(
&self,
context: &HeaderContext,
rejected: Option<&[(String, String)]>,
) -> Result<Vec<(String, String)>, TransportError>
pub fn read( &self, context: &HeaderContext, rejected: Option<&[(String, String)]>, ) -> Result<Vec<(String, String)>, TransportError>
Read the headers for one request, joining the flight of the same client, round and kind when one is in progress.
Sourcepub fn authenticated<T>(
&self,
context: &HeaderContext,
send: impl FnMut(&[(String, String)]) -> Result<T, TransportError>,
) -> Result<T, TransportError>
pub fn authenticated<T>( &self, context: &HeaderContext, send: impl FnMut(&[(String, String)]) -> Result<T, TransportError>, ) -> Result<T, TransportError>
Run one host-authenticated request with this source’s headers. A
refusal carrying details.httpStatus 401 reads the source again, in
the same context, with the refused headers and resends once; a second
401 surfaces.