Skip to content

Instantly share code, notes, and snippets.

@InShade
Created August 16, 2025 19:42
Show Gist options
  • Select an option

  • Save InShade/09551369b8c343a659d5d36d6f2da214 to your computer and use it in GitHub Desktop.

Select an option

Save InShade/09551369b8c343a659d5d36d6f2da214 to your computer and use it in GitHub Desktop.
use reqwest::header;
use reqwest::header::{HeaderMap};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("\n[ - - - - - - - - -");
//
let mut headers = header::HeaderMap::new();
headers.insert("X-MY-HEADER", header::HeaderValue::from_static("qwerty"));
headers.insert("COOKIE", header::HeaderValue::from_static("__test=5f07fc74273ecfcb7706d17a86a11a4e"));
let client = reqwest::Client::builder()
.default_headers(headers)
.build()?;
let r :reqwest::Request = client.get("http://dadou.run/my").build()?;
println!("client_Headers: {:#?}", r.headers());
let resp :reqwest::Response = client.execute(r).await?;
println!("\n Status: {} \n", resp.status());
println!("server_Headers: {:#?}", resp.headers());
let body :String = resp.text().await?;
println!("\nBody: {}", body);
//
println!("- - - - - - - - - ]\n");
Ok(())
}
/*
[ - - - - - - - - -
client_Headers: {}
Status: 200 OK
server_Headers: {
"server": "nginx",
"date": "Sat, 16 Aug 2025 19:29:04 GMT",
"content-type": "application/json",
"content-length": "404",
"connection": "keep-alive",
"vary": "Accept-Encoding",
}
Body: {"request_id": "bfd6001495b88bb7a18d130053a1db08","request_method": "GET","request_time": "0.000","request_body": "","request_l
ength": "101","request_time": "0.000","user_agent": "","via": "","x_forwarded_for": "","proxy_protocol_addr": "","proxy_protocol_port
": "","client_ip": "62.16.2.129","client_port": "3730","server": "Parrot/1.0.2","server_protocol": "HTTP/1.1","at": "2025-08-17T03:29
:04+08:00"}
- - - - - - - - - ]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment