pub struct HttpUpdateResponse<'a> { /* private fields */ }
Expand description
A Candid-encodable representation of an HTTP update response. This struct is used
by the http_update_request
method of the HTTP Gateway Protocol.
This is the same as HttpResponse, excluding the upgrade field.
§Examples
use ic_http_certification::{HttpResponse, HttpUpdateResponse, StatusCode};
let response = HttpResponse::builder()
.with_status_code(StatusCode::OK)
.with_headers(vec![("Content-Type".into(), "text/plain".into())])
.with_body(b"Hello, World!")
.build_update();
let update_response = HttpUpdateResponse::from(response);
assert_eq!(update_response.status_code(), StatusCode::OK);
assert_eq!(update_response.headers(), &[("Content-Type".into(), "text/plain".into())]);
assert_eq!(update_response.body(), b"Hello, World!");
Implementations§
Source§impl<'a> HttpUpdateResponse<'a>
impl<'a> HttpUpdateResponse<'a>
Sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
Returns the HTTP status code of the response.
§Examples
use ic_http_certification::{HttpResponse, StatusCode};
let response = HttpResponse::builder()
.with_status_code(StatusCode::OK)
.build_update();
assert_eq!(response.status_code(), StatusCode::OK);
Sourcepub fn headers(&self) -> &[HeaderField] ⓘ
pub fn headers(&self) -> &[HeaderField] ⓘ
Returns the HTTP headers of the response.
§Examples
use ic_http_certification::HttpResponse;
let response = HttpResponse::builder()
.with_headers(vec![("Content-Type".into(), "text/plain".into())])
.build_update();
assert_eq!(response.headers(), &[("Content-Type".into(), "text/plain".into())]);
Sourcepub fn headers_mut(&mut self) -> &mut Vec<HeaderField> ⓘ
pub fn headers_mut(&mut self) -> &mut Vec<HeaderField> ⓘ
Returns a mutable reference to the HTTP headers of the response.
§Examples
use ic_http_certification::HttpResponse;
let mut response = HttpResponse::builder()
.with_headers(vec![("Content-Type".into(), "text/plain".into())])
.build_update();
response.headers_mut().push(("Content-Length".into(), "13".into()));
assert_eq!(response.headers(), &[("Content-Type".into(), "text/plain".into()), ("Content-Length".into(), "13".into())]);
Sourcepub fn add_header(&mut self, header: HeaderField)
pub fn add_header(&mut self, header: HeaderField)
Adds an additional header to the HTTP response.
§Examples
use ic_http_certification::HttpResponse;
let mut response = HttpResponse::builder()
.with_headers(vec![("Content-Type".into(), "text/plain".into())])
.build_update();
response.add_header(("Content-Length".into(), "13".into()));
assert_eq!(response.headers(), &[("Content-Type".into(), "text/plain".into()), ("Content-Length".into(), "13".into())]);
Trait Implementations§
Source§impl<'a> CandidType for HttpUpdateResponse<'a>
impl<'a> CandidType for HttpUpdateResponse<'a>
Source§impl<'a> Clone for HttpUpdateResponse<'a>
impl<'a> Clone for HttpUpdateResponse<'a>
Source§fn clone(&self) -> HttpUpdateResponse<'a>
fn clone(&self) -> HttpUpdateResponse<'a>
Returns a copy 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<'a> Debug for HttpUpdateResponse<'a>
impl<'a> Debug for HttpUpdateResponse<'a>
Source§impl<'de, 'a> Deserialize<'de> for HttpUpdateResponse<'a>
impl<'de, 'a> Deserialize<'de> for HttpUpdateResponse<'a>
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
Source§impl<'a> From<HttpResponse<'a>> for HttpUpdateResponse<'a>
impl<'a> From<HttpResponse<'a>> for HttpUpdateResponse<'a>
Source§fn from(response: HttpResponse<'a>) -> Self
fn from(response: HttpResponse<'a>) -> Self
Converts to this type from the input type.
Source§impl<'a> PartialEq for HttpUpdateResponse<'a>
impl<'a> PartialEq for HttpUpdateResponse<'a>
impl<'a> Eq for HttpUpdateResponse<'a>
impl<'a> StructuralPartialEq for HttpUpdateResponse<'a>
Auto Trait Implementations§
impl<'a> Freeze for HttpUpdateResponse<'a>
impl<'a> RefUnwindSafe for HttpUpdateResponse<'a>
impl<'a> Send for HttpUpdateResponse<'a>
impl<'a> Sync for HttpUpdateResponse<'a>
impl<'a> Unpin for HttpUpdateResponse<'a>
impl<'a> UnwindSafe for HttpUpdateResponse<'a>
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