pub struct Response { /* private fields */ }
Expand description
A HTTP response.
use oxhttp::model::{HeaderName, Body, Response, Status};
let response = Response::builder(Status::OK)
.with_header(HeaderName::CONTENT_TYPE, "application/json")?
.with_header("X-Custom", "foo")?
.with_body("{\"foo\": \"bar\"}");
assert_eq!(response.status(), Status::OK);
assert_eq!(response.header(&HeaderName::CONTENT_TYPE).unwrap().as_ref(), b"application/json");
assert_eq!(&response.into_body().to_vec()?, b"{\"foo\": \"bar\"}");
Implementations§
source§impl Response
impl Response
pub fn builder(status: Status) -> ResponseBuilder
pub fn status(&self) -> Status
pub fn headers(&self) -> &Headers
pub fn headers_mut(&mut self) -> &mut Headers
pub fn header(&self, name: &HeaderName) -> Option<&HeaderValue>
pub fn append_header( &mut self, name: impl IntoHeaderName, value: impl TryInto<HeaderValue, Error = InvalidHeader> ) -> Result<(), InvalidHeader>
pub fn body(&self) -> &Body ⓘ
pub fn body_mut(&mut self) -> &mut Body ⓘ
pub fn into_body(self) -> Body ⓘ
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Response
impl !RefUnwindSafe for Response
impl !Send for Response
impl !Sync for Response
impl Unpin for Response
impl !UnwindSafe for Response
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more