curl-library
Re: HTTP POST: fail early if unknown data size (read function)
Date: Tue, 14 Jan 2014 11:31:04 +0100
Le 13 janv. 2014 à 16:08, Daniel Stenberg <daniel_at_haxx.se> a écrit :
>> I compared what happens with an HTTP PUT request if the caller forgot to set the expected size via `CURLOPT_INFILESIZE`: in that case, the Content-Length header is omitted (and thus libcurl does not send any negative Content-Length).
>
> Ah yes. Since PUT already works like that, I think it is a good reason for us to make POST do the same!
OK! I will go ahead with this approach and prepare a patch as soon as possible.
>> The Content-Length is explicitly set to 0 by libcurl during the auth negotiation
>> * this is not the case for HTTP PUT (i.e. if a user-defined Content-Length header exists, it is set even at auth negotiation time).
>
> I think that should be considered a bug in the PUT logic, as I'm sure it will seriously confuse servers if we announce a length and then don't actually send that body.
My bad: looking at `Curl_http()` was not enough... I can see that `Curl_add_custom_headers` properly takes care to ignore the user-defined Content-Length during auth neg[1]. So there is no bug.
[1]: https://github.com/bagder/curl/blob/a33e7ed/lib/http.c#L1541-L1545
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-01-14