-
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathhttp1_send_case_sensitive_headers.rs
More file actions
34 lines (30 loc) · 1.14 KB
/
Copy pathhttp1_send_case_sensitive_headers.rs
File metadata and controls
34 lines (30 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use http::{HeaderMap, HeaderName, HeaderValue};
use wreq::{Client, OriginalHeaders};
#[tokio::main]
async fn main() -> wreq::Result<()> {
let client = Client::builder()
.cert_verification(false)
.http1_only()
.build()?;
// Create a request with a case-sensitive header
let mut original_headers = OriginalHeaders::new();
original_headers.insert("Host");
original_headers.insert("X-custom-Header1");
original_headers.insert("x-Custom-Header2");
original_headers.insert(HeaderName::from_static("x-custom-header3"));
// Use the API you're already familiar with
let resp = client
.get("https://tls.peet.ws/api/all")
.original_headers(original_headers)
.headers({
let mut headers = HeaderMap::new();
headers.insert("x-custom-header1", HeaderValue::from_static("value1"));
headers.insert("x-custom-header2", HeaderValue::from_static("value2"));
headers.insert("x-custom-header3", HeaderValue::from_static("value3"));
headers
})
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}