pub struct Request<R = Vec<u8>, D: DirectionMeta = Outbound> { /* private fields */ }Expand description
Single public ICAP request type used by both client and server.
The second type parameter is a direction marker:
Server handlers receive IncomingRequest, whose ICAP metadata is read-only
through accessors. Services may inspect or modify the embedded HTTP message
via Request::embedded_mut or consume it via Request::into_embedded,
but they cannot mutate the ICAP request line, ICAP headers, preview flags,
or advertised Allow values through public API.
Server-only fields (ISTag, chunk trailers) are carried in
DirectionMeta::Meta and are only accessible on IncomingRequest.
OutboundRequest pays zero overhead for those fields.
Implementations§
Source§impl<R, D: DirectionMeta> Request<R, D>
impl<R, D: DirectionMeta> Request<R, D>
Sourcepub const fn icap_headers(&self) -> &HeaderMap
pub const fn icap_headers(&self) -> &HeaderMap
Return ICAP headers supplied on the request.
Sourcepub const fn embedded(&self) -> Option<&EmbeddedHttp<R>>
pub const fn embedded(&self) -> Option<&EmbeddedHttp<R>>
Return embedded HTTP, if this request carries one.
Sourcepub const fn embedded_mut(&mut self) -> Option<&mut EmbeddedHttp<R>>
pub const fn embedded_mut(&mut self) -> Option<&mut EmbeddedHttp<R>>
Return mutable embedded HTTP, if this request carries one.
Sourcepub fn into_embedded(self) -> Option<EmbeddedHttp<R>>
pub fn into_embedded(self) -> Option<EmbeddedHttp<R>>
Consume the request and return the embedded HTTP message.
Sourcepub const fn preview_size(&self) -> Option<usize>
pub const fn preview_size(&self) -> Option<usize>
Return the requested preview size.
Sourcepub const fn is_preview_ieof(&self) -> bool
pub const fn is_preview_ieof(&self) -> bool
Return whether Preview: 0 should be sent as 0; ieof.
Sourcepub const fn allows_204(&self) -> bool
pub const fn allows_204(&self) -> bool
Return whether Allow: 204 is advertised.
Sourcepub const fn allows_206(&self) -> bool
pub const fn allows_206(&self) -> bool
Return whether Allow: 206 is advertised.
Source§impl<R> Request<R, Outbound>
impl<R> Request<R, Outbound>
Sourcepub fn new(method: Method, service: impl Into<String>) -> Self
pub fn new(method: Method, service: impl Into<String>) -> Self
Create a new outbound ICAP request.
Sourcepub fn try_new(method: &str, service: impl Into<String>) -> IcapResult<Self>
pub fn try_new(method: &str, service: impl Into<String>) -> IcapResult<Self>
Create a new outbound ICAP request from a method token without panicking.
Sourcepub fn try_icap_header(self, name: &str, value: &str) -> IcapResult<Self>
pub fn try_icap_header(self, name: &str, value: &str) -> IcapResult<Self>
Try to set or override an ICAP header.
Sourcepub fn icap_header(self, name: &str, value: &str) -> Self
pub fn icap_header(self, name: &str, value: &str) -> Self
Set or override an ICAP header.
§Panics
Panics if name or value is not a valid HTTP header field. Use
Request::try_icap_header for untrusted input.
Sourcepub const fn preview(self, n: usize) -> Self
pub const fn preview(self, n: usize) -> Self
Advertise Preview: n.
Preview: 0 means the client sends an immediate zero-size preview chunk
and waits for either a final response or 100 Continue.
Sourcepub const fn preview_ieof(self) -> Self
pub const fn preview_ieof(self) -> Self
Mark a Preview: 0 request as complete using the ieof chunk extension.
Sourcepub const fn allow_206(self) -> Self
pub const fn allow_206(self) -> Self
Advertise Allow: 206.
The companion server can answer eligible no-modification flows with
206 Partial Content and use-original-body.
Sourcepub const fn is_options(&self) -> bool
pub const fn is_options(&self) -> bool
True for OPTIONS.
Sourcepub const fn embedded_kind(&self) -> Option<EmbeddedHttpKind>
pub const fn embedded_kind(&self) -> Option<EmbeddedHttpKind>
Return the embedded HTTP message kind, if present.
Sourcepub fn validate_for_send(&self) -> IcapResult<()>
pub fn validate_for_send(&self) -> IcapResult<()>
Validate that this request can be serialized as a coherent ICAP request.
This checks method-to-embedded-message compatibility but does not require a buffered body, because streaming sends attach body bytes separately.
Source§impl<R> Request<R, Incoming>
impl<R> Request<R, Incoming>
Sourcepub const fn chunk_trailers(&self) -> &HeaderMap
pub const fn chunk_trailers(&self) -> &HeaderMap
Return chunk trailer headers that accompanied the embedded HTTP body.
RFC 7230 §4.1.2 (applied by RFC 3507 §6.3) allows an ICAP sender to
append HTTP-style Name: Value trailer headers after the zero chunk.
This method returns those headers as parsed from the wire.
The map is empty when no trailers were present.
This accessor is only available on IncomingRequest; outbound client
requests never carry chunk trailers.
Sourcepub fn istag(&self) -> Option<&str>
pub fn istag(&self) -> Option<&str>
Return the ISTag that the server resolved from
ServiceOptions for this request, or None if
no ServiceOptions were configured.
This is the same value that will appear in the ICAP response’s ISTag
header when using
Response::no_content_with_istag
or similar.
This accessor is only available on IncomingRequest; outbound client
requests do not carry an ISTag.
Source§impl Request<Vec<u8>, Outbound>
Client-side convenience: attach embedded HTTP with owned bytes.
impl Request<Vec<u8>, Outbound>
Client-side convenience: attach embedded HTTP with owned bytes.
Sourcepub fn with_http_request_head(self, head: HttpRequest<()>) -> IcapResult<Self>
pub fn with_http_request_head(self, head: HttpRequest<()>) -> IcapResult<Self>
Attach only HTTP request head (no buffered body bytes).
Useful with streaming client APIs such as Client::send_streaming_reader.
Sourcepub fn with_http_response_head(self, head: HttpResponse<()>) -> IcapResult<Self>
pub fn with_http_response_head(self, head: HttpResponse<()>) -> IcapResult<Self>
Attach only HTTP response head (no buffered body bytes).
Useful with streaming client APIs such as Client::send_streaming_reader.
Sourcepub fn with_http_request(self, req: HttpRequest<Vec<u8>>) -> IcapResult<Self>
pub fn with_http_request(self, req: HttpRequest<Vec<u8>>) -> IcapResult<Self>
Attach a complete embedded HTTP request.
This is the usual client-side builder for REQMOD requests when the
HTTP entity body is already available in memory. For large bodies, use
Request::with_http_request_head together with a streaming client
Sourcepub fn with_http_response(self, resp: HttpResponse<Vec<u8>>) -> IcapResult<Self>
pub fn with_http_response(self, resp: HttpResponse<Vec<u8>>) -> IcapResult<Self>
Attach a complete embedded HTTP response.
This is the usual client-side builder for RESPMOD requests when the
HTTP entity body is already available in memory. For large bodies, use
Request::with_http_response_head together with a streaming client
Sourcepub fn with_http_response_and_request_context(
self,
resp: HttpResponse<Vec<u8>>,
orig_req: HttpRequest<()>,
) -> IcapResult<Self>
pub fn with_http_response_and_request_context( self, resp: HttpResponse<Vec<u8>>, orig_req: HttpRequest<()>, ) -> IcapResult<Self>
Attach a complete embedded HTTP response with the original HTTP request context.
Equivalent to with_http_response but also
includes the HTTP request that triggered the response (req-hdr in the
Encapsulated section, RFC 3507 §4.4.1). The ICAP server receives the
original request head via EmbeddedHttp::respmod_request_head.