pub struct HttpResponse {
pub status_code: u16,
pub headers: Vec<(String, String)>,
pub body: ByteBuf,
}Expand description
Represents an HTTP response.
This struct is used to encapsulate the details of an HTTP response, including the status code, headers, and body.
§Examples
use ic_http_types::{HttpResponse};
use serde_bytes::ByteBuf;
let response = HttpResponse {
status_code: 200,
headers: vec![("Content-Type".to_string(), "application/json".to_string())],
body: ByteBuf::from("response body"),
};
assert_eq!(response.status_code, 200);
assert_eq!(response.headers.len(), 1);
assert_eq!(response.body, ByteBuf::from("response body"));Fields§
§status_code: u16The HTTP status code (e.g., 200 for OK, 404 for Not Found).
headers: Vec<(String, String)>A list of headers, where each header is represented as a key-value pair.
body: ByteBufThe body of the response, represented as a byte buffer.
Trait Implementations§
Source§impl CandidType for HttpResponse
impl CandidType for HttpResponse
Source§impl Clone for HttpResponse
impl Clone for HttpResponse
Source§fn clone(&self) -> HttpResponse
fn clone(&self) -> HttpResponse
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HttpResponse
impl Debug for HttpResponse
Source§impl<'de> Deserialize<'de> for HttpResponse
impl<'de> Deserialize<'de> for HttpResponse
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for HttpResponse
impl RefUnwindSafe for HttpResponse
impl Send for HttpResponse
impl Sync for HttpResponse
impl Unpin for HttpResponse
impl UnwindSafe for HttpResponse
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