pub struct HttpClient { /* private fields */ }
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Examples found in repository?
examples/http_client.rs (line 4)
3fn main() {
4 let c = HttpClient::new().unwrap();
5 let r = RequestBuilder::new()
6 .uri("http://ferris2.christoph.app.wasmer.wtf/http-client-test")
7 .body(Body::empty())
8 .unwrap();
9 eprintln!("fetching: {r:?}");
10
11 let res = c.send(r).unwrap();
12 dbg!(&res);
13 assert!(res.status().is_success());
14
15 let body = res.into_body().read_all().unwrap();
16 let s = String::from_utf8(body).unwrap();
17 eprintln!("Response body: {s}");
18
19 assert!(s.contains("http-client-test"));
20}
Sourcepub fn send(&self, request: Request) -> Result<Response, Error>
pub fn send(&self, request: Request) -> Result<Response, Error>
Examples found in repository?
examples/http_client.rs (line 11)
3fn main() {
4 let c = HttpClient::new().unwrap();
5 let r = RequestBuilder::new()
6 .uri("http://ferris2.christoph.app.wasmer.wtf/http-client-test")
7 .body(Body::empty())
8 .unwrap();
9 eprintln!("fetching: {r:?}");
10
11 let res = c.send(r).unwrap();
12 dbg!(&res);
13 assert!(res.status().is_success());
14
15 let body = res.into_body().read_all().unwrap();
16 let s = String::from_utf8(body).unwrap();
17 eprintln!("Response body: {s}");
18
19 assert!(s.contains("http-client-test"));
20}
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for HttpClient
impl RefUnwindSafe for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl UnwindSafe for HttpClient
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