pub struct HttpUpdateRequest<'a> { /* private fields */ }
Expand description
A Candid-encodable representation of an HTTP update request. This struct is
used by the http_update_request
method of the HTTP Gateway Protocol.
This is the same as HttpRequest, excluding the certificate_version property.
§Examples
use ic_http_certification::{HttpUpdateRequest, HttpRequest, Method};
let request = HttpRequest::get("/")
.with_method(Method::GET)
.with_url("/")
.with_headers(vec![("X-Custom-Foo".into(), "Bar".into())])
.with_body(&[1, 2, 3])
.with_certificate_version(2)
.build();
let update_request = HttpUpdateRequest::from(request);
assert_eq!(update_request.method(), Method::GET);
assert_eq!(update_request.url(), "/");
assert_eq!(update_request.headers(), &[("X-Custom-Foo".into(), "Bar".into())]);
assert_eq!(update_request.body(), &[1, 2, 3]);
Implementations§
Source§impl<'a> HttpUpdateRequest<'a>
impl<'a> HttpUpdateRequest<'a>
Sourcepub fn method(&self) -> &Method
pub fn method(&self) -> &Method
Returns the HTTP method of the request.
§Examples
use ic_http_certification::HttpRequest;
let request = HttpRequest::get("/").build_update();
assert_eq!(request.method(), "GET");
Sourcepub fn url(&self) -> &str
pub fn url(&self) -> &str
Returns the URL of the request.
§Examples
use ic_http_certification::HttpRequest;
let request = HttpRequest::get("/").build_update();
assert_eq!(request.url(), "/");
Sourcepub fn headers(&self) -> &[HeaderField] ⓘ
pub fn headers(&self) -> &[HeaderField] ⓘ
Returns the headers of the request.
§Examples
use ic_http_certification::HttpRequest;
let request = HttpRequest::get("/")
.with_headers(vec![("Accept".into(), "text/plain".into())])
.build_update();
assert_eq!(request.headers(), &[("Accept".into(), "text/plain".into())]);
Sourcepub fn body(&self) -> &[u8] ⓘ
pub fn body(&self) -> &[u8] ⓘ
Returns the body of the request.
§Examples
use ic_http_certification::HttpRequest;
let request = HttpRequest::get("/")
.with_body(&[1, 2, 3])
.build_update();
assert_eq!(request.body(), &[1, 2, 3]);
Sourcepub fn get_path(&self) -> HttpCertificationResult<String>
pub fn get_path(&self) -> HttpCertificationResult<String>
Returns the path of the request URL, without domain, query parameters or fragments.
§Examples
use ic_http_certification::HttpRequest;
let request = HttpRequest::get("https://canister.com/sample-asset.txt").build();
assert_eq!(request.get_path().unwrap(), "/sample-asset.txt");
Sourcepub fn get_query(&self) -> HttpCertificationResult<Option<String>>
pub fn get_query(&self) -> HttpCertificationResult<Option<String>>
Returns the query parameters of the request URL, if any, as a string.
§Examples
use ic_http_certification::HttpRequest;
let request = HttpRequest::get("https://canister.com/sample-asset.txt?foo=bar").build();
assert_eq!(request.get_query().unwrap(), Some("foo=bar".to_string()));
Trait Implementations§
Source§impl<'a> CandidType for HttpUpdateRequest<'a>
impl<'a> CandidType for HttpUpdateRequest<'a>
Source§impl<'a> Clone for HttpUpdateRequest<'a>
impl<'a> Clone for HttpUpdateRequest<'a>
Source§fn clone(&self) -> HttpUpdateRequest<'a>
fn clone(&self) -> HttpUpdateRequest<'a>
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<'a> Debug for HttpUpdateRequest<'a>
impl<'a> Debug for HttpUpdateRequest<'a>
Source§impl<'de, 'a> Deserialize<'de> for HttpUpdateRequest<'a>
impl<'de, 'a> Deserialize<'de> for HttpUpdateRequest<'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<HttpRequest<'a>> for HttpUpdateRequest<'a>
impl<'a> From<HttpRequest<'a>> for HttpUpdateRequest<'a>
Source§fn from(req: HttpRequest<'a>) -> Self
fn from(req: HttpRequest<'a>) -> Self
Converts to this type from the input type.
Source§impl<'a> PartialEq for HttpUpdateRequest<'a>
impl<'a> PartialEq for HttpUpdateRequest<'a>
impl<'a> Eq for HttpUpdateRequest<'a>
impl<'a> StructuralPartialEq for HttpUpdateRequest<'a>
Auto Trait Implementations§
impl<'a> Freeze for HttpUpdateRequest<'a>
impl<'a> RefUnwindSafe for HttpUpdateRequest<'a>
impl<'a> Send for HttpUpdateRequest<'a>
impl<'a> Sync for HttpUpdateRequest<'a>
impl<'a> Unpin for HttpUpdateRequest<'a>
impl<'a> UnwindSafe for HttpUpdateRequest<'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