Skip to main content

Request

Struct Request 

Source
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:

  • Outbound is the default client-side builder shape.
  • Incoming is the server-side handler shape.

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>

Source

pub const fn method(&self) -> Method

Return the ICAP method.

Source

pub fn service(&self) -> &str

Return the service path carried in the ICAP URI.

Source

pub const fn icap_headers(&self) -> &HeaderMap

Return ICAP headers supplied on the request.

Source

pub const fn embedded(&self) -> Option<&EmbeddedHttp<R>>

Return embedded HTTP, if this request carries one.

Source

pub const fn embedded_mut(&mut self) -> Option<&mut EmbeddedHttp<R>>

Return mutable embedded HTTP, if this request carries one.

Source

pub fn into_embedded(self) -> Option<EmbeddedHttp<R>>

Consume the request and return the embedded HTTP message.

Source

pub const fn preview_size(&self) -> Option<usize>

Return the requested preview size.

Source

pub const fn is_preview_ieof(&self) -> bool

Return whether Preview: 0 should be sent as 0; ieof.

Source

pub const fn allows_204(&self) -> bool

Return whether Allow: 204 is advertised.

Source

pub const fn allows_206(&self) -> bool

Return whether Allow: 206 is advertised.

Source§

impl<R> Request<R, Outbound>

Source

pub fn new(method: Method, service: impl Into<String>) -> Self

Create a new outbound ICAP request.

Source

pub fn try_new(method: &str, service: impl Into<String>) -> IcapResult<Self>

Create a new outbound ICAP request from a method token without panicking.

Source

pub fn options(service: impl Into<String>) -> Self

Construct OPTIONS request.

Source

pub fn reqmod(service: impl Into<String>) -> Self

Construct REQMOD request.

Source

pub fn respmod(service: impl Into<String>) -> Self

Construct RESPMOD request.

Source

pub fn try_icap_header(self, name: &str, value: &str) -> IcapResult<Self>

Try to set or override an ICAP header.

Source

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.

Source

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.

Source

pub const fn preview_ieof(self) -> Self

Mark a Preview: 0 request as complete using the ieof chunk extension.

Source

pub const fn allow_204(self) -> Self

Advertise Allow: 204.

Source

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.

Source

pub const fn is_mod(&self) -> bool

True for REQMOD/RESPMOD.

Source

pub const fn is_options(&self) -> bool

True for OPTIONS.

Source

pub const fn embedded_kind(&self) -> Option<EmbeddedHttpKind>

Return the embedded HTTP message kind, if present.

Source

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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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

Source

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.

Trait Implementations§

Source§

impl<R: Debug, D: Debug + DirectionMeta> Debug for Request<R, D>
where D::Meta: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R = Vec<u8>, D = Outbound> !Freeze for Request<R, D>

§

impl<R = Vec<u8>, D = Outbound> !RefUnwindSafe for Request<R, D>

§

impl<R = Vec<u8>, D = Outbound> !UnwindSafe for Request<R, D>

§

impl<R, D> Send for Request<R, D>
where <D as DirectionMeta>::Meta: Send, R: Send,

§

impl<R, D> Sync for Request<R, D>
where <D as DirectionMeta>::Meta: Sync, R: Sync,

§

impl<R, D> Unpin for Request<R, D>
where <D as DirectionMeta>::Meta: Unpin, R: Unpin,

§

impl<R, D> UnsafeUnpin for Request<R, D>
where <D as DirectionMeta>::Meta: UnsafeUnpin, R: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more