pub struct HttpHeaders { /* private fields */ }Expand description
A wrapper for worker::Headers with additional methods.
This comes with two additional method which are self.len() and self.is_empty().
Implementations§
Source§impl HttpHeaders
impl HttpHeaders
pub fn new() -> Self
Sourcepub fn get(&self, name: &HeaderName) -> Option<String>
pub fn get(&self, name: &HeaderName) -> Option<String>
Returns all the values of a header within a Headers object with a given name.
§Panics
Panics if HeaderName is constructed from using the method from_static
and the static string is an invalid header or contains spaces.
Eg: Header contains invalid header’s name or spaces.
Sourcepub fn has(&self, name: &HeaderName) -> bool
pub fn has(&self, name: &HeaderName) -> bool
Returns a boolean stating whether a Headers object contains a certain header.
§Panics
Panics if HeaderName is constructed from using the method from_static
and the static string is an invalid header or contains spaces.
Eg: Header contains invalid header’s name or spaces.
Sourcepub fn append(
&mut self,
name: &HeaderName,
value: &HeaderValue,
) -> Result<(), Error>
pub fn append( &mut self, name: &HeaderName, value: &HeaderValue, ) -> Result<(), Error>
Append a header, keeping any that were set with an equivalent field name.
§Errors
Errors are returned if the header name or value is invalid (e.g. contains spaces)
§Panics
Panics if HeaderName or HeaderValue is constructed from using the method from_static
and the static string is an invalid header or contains spaces.
Eg: Header contains invalid header’s name or spaces.
Sourcepub fn set(
&mut self,
name: &HeaderName,
value: &HeaderValue,
) -> Result<(), Error>
pub fn set( &mut self, name: &HeaderName, value: &HeaderValue, ) -> Result<(), Error>
Sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist.
§Errors
Errors are returned if the header name or value is invalid (e.g. contains spaces)
§Panics
Panics if HeaderName or HeaderValue is constructed from using the method from_static
and the static string is an invalid header or contains spaces.
Eg: Header contains invalid header’s name or spaces.
Sourcepub fn delete(&mut self, name: &HeaderName) -> Result<(), Error>
pub fn delete(&mut self, name: &HeaderName) -> Result<(), Error>
Deletes a header from a Headers object.
§Errors
Errors are returned if the header name or value is invalid (e.g. contains spaces) or if the JS Headers object’s guard is immutable (e.g. for an incoming request)
§Panics
Panics if HeaderName is constructed from using the method from_static
and the static string is an invalid header or contains spaces.
Eg: Header contains invalid header’s name or spaces.
Sourcepub fn entries(
&self,
) -> Map<Map<IntoIter, fn(_: Result<JsValue, JsValue>) -> Array>, fn(_: Array) -> (String, String)> ⓘ
pub fn entries( &self, ) -> Map<Map<IntoIter, fn(_: Result<JsValue, JsValue>) -> Array>, fn(_: Array) -> (String, String)> ⓘ
Returns an iterator allowing to go through all key/value pairs contained in this object.
Methods from Deref<Target = Headers>§
Sourcepub fn get(&self, name: &str) -> Result<Option<String>, Error>
pub fn get(&self, name: &str) -> Result<Option<String>, Error>
Returns all the values of a header within a Headers object with a given name.
Returns an error if the name is invalid (e.g. contains spaces)
Sourcepub fn has(&self, name: &str) -> Result<bool, Error>
pub fn has(&self, name: &str) -> Result<bool, Error>
Returns a boolean stating whether a Headers object contains a certain header.
Returns an error if the name is invalid (e.g. contains spaces)
Sourcepub fn append(&mut self, name: &str, value: &str) -> Result<(), Error>
pub fn append(&mut self, name: &str, value: &str) -> Result<(), Error>
Returns an error if the name is invalid (e.g. contains spaces)
Sourcepub fn set(&mut self, name: &str, value: &str) -> Result<(), Error>
pub fn set(&mut self, name: &str, value: &str) -> Result<(), Error>
Sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist.
Returns an error if the name is invalid (e.g. contains spaces)
Sourcepub fn delete(&mut self, name: &str) -> Result<(), Error>
pub fn delete(&mut self, name: &str) -> Result<(), Error>
Deletes a header from a Headers object.
Returns an error if the name is invalid (e.g. contains spaces)
or if the JS Headers object’s guard is immutable (e.g. for an incoming request)
Sourcepub fn entries(
&self,
) -> Map<Map<IntoIter, fn(_: Result<JsValue, JsValue>) -> Array>, fn(_: Array) -> (String, String)> ⓘ
pub fn entries( &self, ) -> Map<Map<IntoIter, fn(_: Result<JsValue, JsValue>) -> Array>, fn(_: Array) -> (String, String)> ⓘ
Returns an iterator allowing to go through all key/value pairs contained in this object.
Trait Implementations§
Source§impl Clone for HttpHeaders
impl Clone for HttpHeaders
Source§fn clone(&self) -> HttpHeaders
fn clone(&self) -> HttpHeaders
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more