client.rs |
|
2480 |
error.rs |
|
4724 |
lib.rs |
This module provides idiomatic Rust data structure for building and sending
HTTP requests through Necko, the networking component of Firefox and
Thunderbird.
## Sending requests
A simple request can be built and sent using the helper methods on
[`Client`]:
```rust
# async fn run() -> crate::Result<()> {
let client = Client::new();
let url = Url::parse("https://example.com")?;
let response = client.get(&url)
.send()
.await?;
# Ok(())
# }
```
Setting a request's body is done this way:
```rust
use url::Url;
# async fn run() -> crate::Result<()> {
let client = Client::new();
let url = Url::parse("https://example.com")?;
let response = client.post(&url)
.body(
"{\"foo\": \"bar\"}",
"application/json",
)
.send()
.await?;
# Ok(())
# }
``` |
1345 |
request.rs |
|
11202 |
response.rs |
|
2675 |