-
Notifications
You must be signed in to change notification settings - Fork 121
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 which return a content-length incorrectly Err #321
Comments
Can you run with |
The documentation for HTTP HEAD explicitly call out
|
Oh. I think this is a libcurl / isahc problem, it seems familiar. @Firstyear try using this in your surf = { version = "2.3", default-features = false, features = ["h1-client", "encoding"] } |
RUST_BACKTRACE=1 for @Fishrock123 (no changes to features)
With |
We may want to report that to the isahc repo, but note that we run 0.9 instead of 1.x |
Is there a major set of changes to move to 1.x first? And did you want me to report that issue or can we proxy it over somehow? |
@Firstyear We probably need to introduce versioned feature flags ... Please report this to Isahc, yeah |
Actually this looks the same as #218 perhaps? I dug into this example program with LLDB and figured out the cause; it is kind of a Surf bug, and kind of an Isahc bug. Let's start with the former. Surf is constructing a request for Isahc to send, and gives it a request body to upload of length 0. Note that this is not the same as the absence of a request body! The way I interpret the spec (RFC 7230, Section 3.3), there is a clear semantic difference between a zero-length payload and the absence of a payload. In particular:
Or maybe even more clear:
This implies that a message with a Maybe Isahc should have represented bodies as Now this is a relatively minor bug, but unfortunately it triggers an Isahc bug described in sagebind/isahc#342, in which Isahc fails trying to read a response body when the server sends a response with a |
The issue you are describing seems like it's an api shortcoming of how isahc works with the I think I can work around this with some extra code though, for better or worse... |
If there is no body then don't construct a zero-lengthed body. Fixes: http-rs/surf#321 Fixes: http-rs/surf#218
Could someone check if this patch fixes the issue? http-rs/http-client#97 (Edit: original patch was wrong, should be good now.) |
If there is no body then don't construct a zero-lengthed body. Fixes: http-rs/surf#321 Fixes: http-rs/surf#218
Regarding isahc 0.9 vs 1.x - we ("we" as in who ever did this at the time, who was not really me (i.e. pre 2.x)) messed up and made feature flags on multiple clients which do not pin to their major versions...
|
If there is no body then don't construct a zero-lengthed body. Fixes: http-rs/surf#321 Fixes: http-rs/surf#218
Tested with:
Can confirm that it works now :) Thank you! |
There may be another way to trigger this, as I've started to see other calls have this issue now.
Perhaps the fixed branch is incomplete? |
@Fishrock123 I think I've solved it. Looking at |
Some urls will return a content-length during head requests. Surf incorrectly assumes that this means there is a body present and will error:
The following reproducer can show this behaviour:
Expected Results: Surf should allow head requests to proceed even if a content-length is returned.
The text was updated successfully, but these errors were encountered: