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

After converting reqwest::Response to http::Response the size hint is lost #2497

Open
blind-oracle opened this issue Dec 12, 2024 · 1 comment · May be fixed by hyperium/http-body#137
Open
Labels
E-easy Effort: Easy! Start here :D E-pr-welcome The feature is welcome to be added, instruction should be found in the issue. S-needs-more-info Status: More information is required to understand the issue.

Comments

@blind-oracle
Copy link

blind-oracle commented Dec 12, 2024

It seems that body size information is gone, e.g.

#[cfg(test)]
mod test {
    use http_body::Body as _;
    use reqwest::ResponseBuilderExt;

    #[test]
    fn test() {
        let url = url::Url::parse("http://foo.bar").unwrap();
        let body = reqwest::Body::from("foo");
        let resp = http::response::Builder::new()
            .status(200)
            .url(url)
            .body(body)
            .unwrap();

        assert_eq!(resp.body().size_hint().exact(), Some(3));
        let resp = reqwest::Response::from(resp);
        assert_eq!(resp.content_length(), Some(3));
        let resp: http::Response<_> = resp.into();
        assert_eq!(resp.body().size_hint().exact(), Some(3));
    }
}

The first two asserts succeed, the last one fails. It would be nice if we can make this work.

@seanmonstar seanmonstar added the E-pr-welcome The feature is welcome to be added, instruction should be found in the issue. label Dec 13, 2024
@seanmonstar
Copy link
Owner

Interesting! Anyone interested in digging it is welcome, it shouldn't be too complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Effort: Easy! Start here :D E-pr-welcome The feature is welcome to be added, instruction should be found in the issue. S-needs-more-info Status: More information is required to understand the issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants