You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the following code, the output from the printed body is ciphertext, not the decrypted plaintext of the accessed site. Is there a specific way that I am missing to specify a Request for hyper and still receive the decrypted contents?
let tls = rustls::ClientConfig::builder()
.with_safe_defaults()
.with_native_roots()
.with_no_client_auth();
let https = hyper_rustls::HttpsConnectorBuilder::new()
.with_tls_config(tls)
.https_or_http()
.enable_http1()
.build();
let url = (String::from("https://") + &temp).parse::<hyper::Uri>()?;
let request = Request::get(url)
.method(Method::GET)
.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8")
.header("Accept-Encoding", "gzip, deflate, br")
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0")
.body(Body::empty())?;
let client: Client<_, hyper::Body> = Client::builder().build(https);
let resp = match tokio::time::timeout(tokio::time::Duration::from_secs(10), client
.request(request)).await {
Ok(x) => {
match x {
Ok(y) => y,
Err(err) => {
println!("{domain}: {err:?}");
return Err(err.into())
}
}
}
Err(err) => {
println!("{domain}: {err:?}");
return Err(err.into())
}
};
let body = resp.into_body();
let body = hyper::body::to_bytes(body).await;
let bytes = match body {
Ok(x) => x,
Err(err) => {
println!("{domain}: {err:?}");
return Err(err.into())
}
};
let text = String::from_utf8_lossy(&bytes);
println!("{text:?}");
```
The text was updated successfully, but these errors were encountered:
This is a complete guess, but I think it is compression and not encryption.
This line says you are happy to receive and decompress gzip, deflate or brotli bodies:
.header("Accept-Encoding", "gzip, deflate, br")
But there is nothing in the remainder of your program that looks at the content-encoding header of the response and decompresses the body if necessary. hyper doesn't do this for you. However, reqwest does (AIUI) include transparent gzip decompression by default.
On Aug 2, 2023, 01:58, ctz wrote:
This is a complete guess, but I think it is compression and not encryption.
This line says you are happy to receive and decompress gzip, deflate or brotli bodies:
> .header("Accept-Encoding", "gzip, deflate, br")
But there is nothing in the remainder of your program that looks at the content-encoding body of the response and decompresses the body if necessary. hyper doesn't do this for you. However, reqwest does (AIUI) include transparent gzip decompression by default.
—
Reply to this email directly, [view it on GitHub](#216 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AGHV5RNKXO5PAWVNH62OZU3XTHUBPANCNFSM6AAAAAA3AVOTVE).
You are receiving this because you authored the thread.Message ID: ***@***.***>
Using the following code, the output from the printed body is ciphertext, not the decrypted plaintext of the accessed site. Is there a specific way that I am missing to specify a
Request
for hyper and still receive the decrypted contents?The text was updated successfully, but these errors were encountered: