-
Notifications
You must be signed in to change notification settings - Fork 49
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
fix: curl - avoid zero-sized HEAD bodies #97
base: main
Are you sure you want to change the base?
Conversation
c8eeaff
to
44cba08
Compare
If there is no body then don't construct a zero-lengthed body. Fixes: http-rs/surf#321 Fixes: http-rs/surf#218
44cba08
to
07b7317
Compare
Confirmed working: http-rs/surf#321 (comment) |
@sagebind if you wouldn't mind, I'd like to know if this patch looks correct to you. |
for (name, value) in req.iter() { | ||
builder = builder.header(name.as_str(), value.as_str()); | ||
} | ||
let request = builder.body(()).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right to me at all -- does Surf/http-client always know the size of a request body being uploaded? Because what this code seems to be doing is, "If we don't know the size of the request body, then just don't send one at all." What if you are streaming a request body of unknown size? I'd think that this change would break that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, from Isahc's perspective a body of ()
and a body of isahc::Body::empty()
are identical, so you can use that instead so that you don't have to deal with the type shenanigans of dealing with two different cases of T
in Request<T>
.
This doesn't seem to be aiming to correct the right thing here. The problem is that Isahc understands three different scenarios:
The problem is that Surf never indicates the third case to Isahc, only one of the first two cases. |
If there is no body then don't construct a zero-lengthed body.
Fixes: http-rs/surf#321
Fixes: http-rs/surf#218