Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection_verbose does not emit the response headers and body #2278

Open
ogarcia opened this issue May 6, 2024 · 1 comment
Open

connection_verbose does not emit the response headers and body #2278

ogarcia opened this issue May 6, 2024 · 1 comment
Labels
upstream Blocked: upstream. Depends on a dependency to make a change first.

Comments

@ogarcia
Copy link

ogarcia commented May 6, 2024

Given the following code:

#[tokio::main]
async fn main() {
    env_logger::init();  // RUST_LOG=trace
    let client = reqwest::Client::builder()
        .connection_verbose(true)
        .build()
        .expect("Client::new()");
    let _ = client.get("https://eu.httpbin.org/get")
        .send()
        .await;
}

If executed with reqwest v0.11.27 it outputs the response haeaders and body log correctly:

% RUST_LOG=trace cargo run
[2024-05-06T06:57:18Z DEBUG reqwest::connect] starting new connection: https://eu.httpbin.org/
[2024-05-06T06:57:19Z TRACE reqwest::connect::verbose] 7e642c23 write: b"GET /get HTTP/1.1\r\naccept: */*\r\nhost: eu.httpbin.org\r\n\r\n"
[2024-05-06T06:57:19Z TRACE reqwest::connect::verbose] 7e642c23 read: b"HTTP/1.1 200 OK\r\nDate: Mon, 06 May 2024 06:57:19 GMT\r\nContent-Type: application/json\r\nContent-Length: 228\r\nConnection: keep-alive\r\nServer: gunicorn/19.9.0\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Credentials: true\r\n\r\n"
[2024-05-06T06:57:19Z TRACE reqwest::connect::verbose] 7e642c23 read: b"{\n  \"args\": {}, \n  \"headers\": {\n    \"Accept\": \"*/*\", \n    \"Host\": \"eu.httpbin.org\", \n    \"X-Amzn-Trace-Id\": \"Root=1-66387f4f-25a929b24f3cb1f5250ce27f\"\n  }, \n  \"origin\": \"91.116.229.190\", \n  \"url\": \"https://eu.httpbin.org/get\"\n}\n"

But if run it with 0.12 it doesn't:

[2024-05-06T06:56:30Z TRACE hyper_util::client::legacy::pool] checkout waiting for idle connection: ("https", eu.httpbin.org)
[2024-05-06T06:56:30Z DEBUG reqwest::connect] starting new connection: https://eu.httpbin.org/
[2024-05-06T06:56:30Z TRACE hyper_util::client::legacy::connect::http] Http::connect; scheme=Some("https"), host=Some("eu.httpbin.org"), port=None
[2024-05-06T06:56:30Z DEBUG hyper_util::client::legacy::connect::dns] resolving host="eu.httpbin.org"
[2024-05-06T06:56:30Z DEBUG hyper_util::client::legacy::connect::http] connecting to 3.211.223.136:443
[2024-05-06T06:56:30Z DEBUG hyper_util::client::legacy::connect::http] connected to 3.211.223.136:443
[2024-05-06T06:56:30Z TRACE hyper_util::client::legacy::client] http1 handshake complete, spawning background dispatcher task
[2024-05-06T06:56:30Z TRACE hyper_util::client::legacy::pool] checkout dropped for ("https", eu.httpbin.org)
[2024-05-06T06:56:30Z TRACE reqwest::connect::verbose] 52085a80 write: b"GET /get HTTP/1.1\r\naccept: */*\r\nhost: eu.httpbin.org\r\n\r\n"
[2024-05-06T06:56:30Z TRACE reqwest::connect::verbose] TODO: verbose poll_read
[2024-05-06T06:56:30Z TRACE reqwest::connect::verbose] TODO: verbose poll_read
[2024-05-06T06:56:30Z TRACE hyper_util::client::legacy::pool] put; add idle connection for ("https", eu.httpbin.org)
[2024-05-06T06:56:30Z DEBUG hyper_util::client::legacy::pool] pooling idle connection for ("https", eu.httpbin.org)

The truth is that I don't know if those two TODO lines it emits refer to this.

@seanmonstar
Copy link
Owner

Oh yes, that got left behind in the upgrade, as the TODO reveals. Woops!

Looking in the source, the problem is that hyper's ReadBuf/ReadBufCursor don't currently have a way to inspect what was just read. We'd need to propose a method in the hyper repo to do that.

@seanmonstar seanmonstar added the upstream Blocked: upstream. Depends on a dependency to make a change first. label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Blocked: upstream. Depends on a dependency to make a change first.
Projects
None yet
Development

No branches or pull requests

2 participants