-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Between 0.12.2 and 0.12.3 a change was made that meant sending a request with no body no longer sends the content length header. This seems to be because of #2207. This would be correct for GET requests I believe, but it seems to also be affecting PUT requests at least, and looking at the changes it is probably affecting ALL http methods.
It seems that Google's Https load balancer will reject any requests that do not have a chunked body (so unchunked or no body) that do not have the content length header (or that header not having a valid number, not sure which rule is actually being hit now). I do not know enough about the relevant standards to say confidently who is actually in the wrong here. However my understanding of this paragraph is that a user-agent (Reqwest in this case) SHOULD be sending the Content-Length header even if the value is 0, unless the METHOD (GET for example) should never have a body. This implies to me that reqwest is the one at fault for not being HTTP/1.1 compliant. It does seem a bit silly to have users manually set the content-length to 0 when not providing a body for a non-GET request.
I ran into this when adding reqwest to a project in a workspace after 0.12.3 released which then caused a different project in the workspace to suddenly stop working (as cargo will use the highest version of a dep for all projects in a workspace) as the Spotify API was suddenly and without warning returning the Google load balancer error page with status 411 Length Required. For now I have just downgraded explicitly to 0.12.2 across the workspace.