[−][src]Struct tide::Response
An HTTP response
Implementations
impl Response
[src]
#[must_use]pub fn new<S>(status: S) -> Self where
S: TryInto<StatusCode>,
S::Error: Debug,
[src]
S: TryInto<StatusCode>,
S::Error: Debug,
Create a new instance.
#[must_use]pub fn status(&self) -> StatusCode
[src]
Returns the statuscode.
#[must_use]pub fn set_status(self, status: StatusCode) -> Self
[src]
Set the statuscode.
#[must_use]pub fn len(&self) -> Option<usize>
[src]
Get the length of the body.
#[must_use]pub fn is_empty(&self) -> Option<bool>
[src]
Checks if the body is empty.
#[must_use]pub fn header(&self, name: impl Into<HeaderName>) -> Option<&HeaderValues>
[src]
Get an HTTP header.
#[must_use]pub fn header_mut(
&mut self,
name: impl Into<HeaderName>
) -> Option<&mut HeaderValues>
[src]
&mut self,
name: impl Into<HeaderName>
) -> Option<&mut HeaderValues>
Get an HTTP header mutably.
pub fn remove_header(
&mut self,
name: impl Into<HeaderName>
) -> Option<HeaderValues>
[src]
&mut self,
name: impl Into<HeaderName>
) -> Option<HeaderValues>
Remove a header.
pub fn insert_header(
&mut self,
key: impl Into<HeaderName>,
value: impl ToHeaderValues
)
[src]
&mut self,
key: impl Into<HeaderName>,
value: impl ToHeaderValues
)
Insert an HTTP header.
pub fn append_header(
&mut self,
key: impl Into<HeaderName>,
value: impl ToHeaderValues
)
[src]
&mut self,
key: impl Into<HeaderName>,
value: impl ToHeaderValues
)
Append an HTTP header.
#[must_use]pub fn iter(&self) -> Iter
[src]
An iterator visiting all header pairs in arbitrary order.
#[must_use]pub fn iter_mut(&mut self) -> IterMut
[src]
An iterator visiting all header pairs in arbitrary order, with mutable references to the values.
#[must_use]pub fn header_names(&self) -> Names
[src]
An iterator visiting all header names in arbitrary order.
#[must_use]pub fn header_values(&self) -> Values
[src]
An iterator visiting all header values in arbitrary order.
#[must_use]pub fn content_type(&self) -> Option<Mime>
[src]
Get the response content type as a Mime
.
This gets the request Content-Type
header.
pub fn set_content_type(&mut self, mime: impl Into<Mime>)
[src]
Set the response content type from a MIME
.
This sets the response Content-Type
header.
pub fn set_body(&mut self, body: impl Into<Body>)
[src]
Set the body reader.
pub fn take_body(&mut self) -> Body
[src]
Take the response body as a Body
.
pub fn swap_body(&mut self, body: &mut Body)
[src]
Swaps the value of the body with another body, without deinitializing either one.
Examples
use tide::Response; let mut req = Response::new(200); req.set_body("Hello, Nori!"); let mut body = "Hello, Chashu!".into(); req.swap_body(&mut body); let mut string = String::new(); body.read_to_string(&mut string).await?; assert_eq!(&string, "Hello, Nori!");
pub fn insert_cookie(&mut self, cookie: Cookie<'static>)
[src]
Insert cookie in the cookie jar.
pub fn remove_cookie(&mut self, cookie: Cookie<'static>)
[src]
Removes the cookie. This instructs the CookiesMiddleware
to send a cookie with empty value
in the response.
Warning
Take care when calling this function with a cookie that was returned by
Request::cookie
. As per section 5.3 step 11 of RFC 6265, a new
cookie is only treated as the same as an old one if it has a matching name, domain and
path.
The domain and path are not sent to the server on subsequent HTTP requests, so if a cookie was originally set with a domain and/or path, calling this function on a cookie with the same name but with either a different, or no, domain and/or path will lead to us sending an empty cookie that the user agent will treat as unrelated to the original one, and will thus not remove the old one.
To avoid this you can manually set the domain and
path as necessary after retrieving the cookie using
Request::cookie
.
#[must_use]pub fn ext<T: Send + Sync + 'static>(&self) -> Option<&T>
[src]
Get a response scoped extension value.
pub fn insert_ext<T: Send + Sync + 'static>(self, val: T)
[src]
Set a response scoped extension value.
pub fn from_res<T>(value: T) -> Self where
T: Into<Response>,
[src]
T: Into<Response>,
Create a tide::Response
from a type that can be converted into an
http_types::Response
.
Trait Implementations
impl AsMut<Headers> for Response
[src]
impl AsMut<Response> for Response
[src]
impl AsRef<Headers> for Response
[src]
impl AsRef<Response> for Response
[src]
impl Debug for Response
[src]
impl<'a> From<&'a str> for Response
[src]
impl From<Response> for Response
[src]
impl From<String> for Response
[src]
impl From<Value> for Response
[src]
impl<'_> Index<&'_ str> for Response
[src]
type Output = HeaderValues
The returned type after indexing.
fn index(&self, name: &str) -> &HeaderValues
[src]
Returns a reference to the value corresponding to the supplied name.
Panics
Panics if the name is not present in Response
.
impl Index<HeaderName> for Response
[src]
type Output = HeaderValues
The returned type after indexing.
fn index(&self, name: HeaderName) -> &HeaderValues
[src]
Returns a reference to the value corresponding to the supplied name.
Panics
Panics if the name is not present in Response
.
impl<T: AsRef<str>> Into<Response> for Redirect<T>
[src]
impl<'_, T: AsRef<str>> Into<Response> for &'_ Redirect<T>
[src]
impl<State: Send + Sync + 'static> Into<Response> for Request<State>
[src]
impl Into<Response> for Response
[src]
impl IntoIterator for Response
[src]
type Item = (HeaderName, HeaderValues)
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Returns a iterator of references over the remaining items.
impl<'a> IntoIterator for &'a Response
[src]
type Item = (&'a HeaderName, &'a HeaderValues)
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a> IntoIterator for &'a mut Response
[src]
type Item = (&'a HeaderName, &'a mut HeaderValues)
The type of the elements being iterated over.
type IntoIter = IterMut<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl !UnwindSafe for Response
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> Sealed<T> for T where
T: ?Sized,
T: ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,