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

head requests with content length fail #341

Closed
Firstyear opened this issue Aug 26, 2021 · 4 comments · Fixed by #343
Closed

head requests with content length fail #341

Firstyear opened this issue Aug 26, 2021 · 4 comments · Fixed by #343
Labels
bug Something is borken

Comments

@Firstyear
Copy link

http-rs/surf#321

Using isahc as a backend to surf, I noted that doing head requests to servers which return a content length fail due to no body being present. The surf developers isolated this to isahc, but they also noted they are using 0.9.

Is this behaviour fixed in 1.0? Or would it be a valid issue in 1.0 as well?

Thanks!

@sagebind
Copy link
Owner

Thanks for bringing this to my attention! In particular, I think this might be what is causing Surf to error:

fn main() -> Result<(), isahc::Error> {
    let response = isahc::head("http://download.opensuse.org/update/tumbleweed/repodata/repomd.xml")?;

    println!("Status: {}", response.status());
    println!("Headers: {:#?}", response.headers());
    println!("Body is empty: {}", response.body().is_empty()); // This should be true, but is false instead

    Ok(())
}

Isahc doesn't throw any errors, but it is returning a streaming body (which happens to return no bytes) instead of an "empty" body. Reproduced with 1.5.0.

I can backport a fix to 0.9.x as well if Surf really wants to avoid upgrading.

@sagebind sagebind added the bug Something is borken label Aug 28, 2021
@Firstyear
Copy link
Author

It might be best for @Fishrock123 to comment on the 0.9 backport :)

Thanks so much for finding the cause so quickly!

@sagebind
Copy link
Owner

sagebind commented Aug 28, 2021

Turns out this actually isn't the underlying problem with the Surf issue in question, #342 is, but this bug deserves to be fixed too! I'll leave this issue open to focus on Body::is_empty not returning true when it should.

@sagebind
Copy link
Owner

This is now fixed in the 1.5.1 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is borken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants