pub struct HttpHeaders<'a> {
pub raw: &'a mut http,
}Expand description
HTTP headers of an object, wrapping HTTP from Varnish
Fields§
§raw: &'a mut httpImplementations§
Source§impl HttpHeaders<'_>
impl HttpHeaders<'_>
Sourcepub fn set_header(&mut self, name: &str, value: &str) -> VclResult<()>
pub fn set_header(&mut self, name: &str, value: &str) -> VclResult<()>
Append a new header using name and value. This can fail if we run out of internal slots
to store the new header
Sourcepub fn unset_header(&mut self, name: &str)
pub fn unset_header(&mut self, name: &str)
Remove all headers matching name (case-insensitive). No-op if the header is absent.
Sourcepub fn method(&self) -> Option<StrOrBytes<'_>>
pub fn method(&self) -> Option<StrOrBytes<'_>>
Method of an HTTP request, None for a response
Sourcepub fn url(&self) -> Option<StrOrBytes<'_>>
pub fn url(&self) -> Option<StrOrBytes<'_>>
URL of an HTTP request, None for a response
Sourcepub fn set_url(&mut self, value: &str) -> VclResult<()>
pub fn set_url(&mut self, value: &str) -> VclResult<()>
Set the URL of this HTTP request.
This updates the URL (path and query) component of the HTTP request line associated
with this HttpHeaders object. It is only meaningful for request objects; for responses
the corresponding url accessor will return None.
The new value must fit in the underlying Varnish workspace; otherwise an error is returned.
§Examples
// Change the URL of the current request before it is processed further.
http.set_url("/new/path?foo=bar")?;
assert_eq!(http.url().unwrap().as_str(), "/new/path?foo=bar");Sourcepub fn proto(&self) -> Option<StrOrBytes<'_>>
pub fn proto(&self) -> Option<StrOrBytes<'_>>
Protocol of an object
It should exist for both requests and responses, but the Option is maintained for
consistency.
Sourcepub fn status(&self) -> Option<StrOrBytes<'_>>
pub fn status(&self) -> Option<StrOrBytes<'_>>
Response status, None for a request
Sourcepub fn set_status(&mut self, status: u16)
pub fn set_status(&mut self, status: u16)
Set the response status, it will also set the reason
Sourcepub fn reason(&self) -> Option<StrOrBytes<'_>>
pub fn reason(&self) -> Option<StrOrBytes<'_>>
Response reason, None for a request
Sourcepub fn set_reason(&mut self, value: &str) -> VclResult<()>
pub fn set_reason(&mut self, value: &str) -> VclResult<()>
Set reason
Sourcepub fn weaken_etag(&mut self) -> VclResult<()>
pub fn weaken_etag(&mut self) -> VclResult<()>
Weaken the ETag header if present and not already weak.
Implements RFC 2616 §3.11 ETag
weakening: if the ETag header exists and does not already start with W/, it is
replaced with W/<original-value>.
Sourcepub fn header(&self, name: &str) -> Option<StrOrBytes<'_>>
pub fn header(&self, name: &str) -> Option<StrOrBytes<'_>>
Returns the value of a header based on its name
The header names are compared in a case-insensitive manner
Sourcepub fn iter(&self) -> HttpHeadersIter<'_> ⓘ
pub fn iter(&self) -> HttpHeadersIter<'_> ⓘ
Iterate over (name, value) pairs for all headers, excluding the request/status line.