RequestHeader

Struct RequestHeader 

Source
pub struct RequestHeader { /* private fields */ }
Expand description

The HTTP request header type.

This type is similar to http::request::Parts but preserves header name case. It also preserves request path even if it is not UTF-8.

RequestHeader implements Deref for http::request::Parts so it can be used as it in most places.

Implementations§

Source§

impl RequestHeader

Source

pub fn build( method: impl TryInto<Method>, path: &[u8], size_hint: Option<usize>, ) -> Result<RequestHeader, Box<Error>>

Create a new RequestHeader with the given method and path.

The path can be non UTF-8.

Source

pub fn build_no_case( method: impl TryInto<Method>, path: &[u8], size_hint: Option<usize>, ) -> Result<RequestHeader, Box<Error>>

Create a new RequestHeader with the given method and path without preserving header case.

A RequestHeader created from this type is more space efficient than those from Self::build().

Use this method if reading from or writing to HTTP/2 sessions where header case doesn’t matter anyway.

Source

pub fn append_header( &mut self, name: impl IntoCaseHeaderName, value: impl TryInto<HeaderValue>, ) -> Result<bool, Box<Error>>

Append the header name and value to self.

If there are already some headers under the same name, a new value will be added without any others being removed.

Source

pub fn insert_header( &mut self, name: impl IntoCaseHeaderName, value: impl TryInto<HeaderValue>, ) -> Result<(), Box<Error>>

Insert the header name and value to self.

Different from Self::append_header(), this method will replace all other existing headers under the same name (case-insensitive).

Source

pub fn remove_header<'a, N>(&mut self, name: &'a N) -> Option<HeaderValue>
where &'a N: 'a + AsHeaderName, N: ?Sized,

Remove all headers under the name

Source

pub fn header_to_h1_wire(&self, buf: &mut impl BufMut)

Write the header to the buf in HTTP/1.1 wire format.

The header case will be preserved.

Source

pub fn set_method(&mut self, method: Method)

Set the request method

Source

pub fn set_uri(&mut self, uri: Uri)

Set the request URI

Source

pub fn set_raw_path(&mut self, path: &[u8]) -> Result<(), Box<Error>>

Set the request URI directly via raw bytes.

Generally prefer Self::set_uri() to modify the header’s URI if able.

This API is to allow supporting non UTF-8 cases.

Source

pub fn set_send_end_stream(&mut self, send_end_stream: bool)

Set whether we send an END_STREAM on H2 request HEADERS if body is empty.

Source

pub fn send_end_stream(&self) -> Option<bool>

Returns if we support sending an END_STREAM on H2 request HEADERS if body is empty, returns None if not H2.

Source

pub fn raw_path(&self) -> &[u8]

Return the request path in its raw format

Non-UTF8 is supported.

Source

pub fn uri_file_extension(&self) -> Option<&str>

Return the file extension of the path

Source

pub fn set_version(&mut self, version: Version)

Set http version

Source

pub fn as_owned_parts(&self) -> Parts

Clone self into http::request::Parts.

Trait Implementations§

Source§

impl AsRef<Parts> for RequestHeader

Source§

fn as_ref(&self) -> &Parts

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for RequestHeader

Source§

fn clone(&self) -> RequestHeader

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RequestHeader

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deref for RequestHeader

Source§

type Target = Parts

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<RequestHeader as Deref>::Target

Dereferences the value.
Source§

impl From<Parts> for RequestHeader

Source§

fn from(parts: Parts) -> RequestHeader

Converts to this type from the input type.
Source§

impl From<RequestHeader> for Parts

Source§

fn from(resp: RequestHeader) -> Parts

Converts to this type from the input type.

Auto Trait Implementations§

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> Upcastable for T
where T: Any + Send + Sync + 'static,

Source§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

upcast ref
Source§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

upcast mut ref
Source§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

upcast boxed dyn
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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