cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: HTTP POST: fail early if unknown data size (read function)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 13 Jan 2014 16:08:30 +0100 (CET)

On Sun, 12 Jan 2014, CÚdric Deltheil wrote:

> 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!

> In other words, this means the HTTP PUT[1] and HTTP POST[2] behaviors are
> different.

There's really no good reason for that.

> The Content-Length is explicitly set to 0 by libcurl during the auth
> negotiation (i.e before the final request). Here again the behavior between
> PUT and POST are different:

> * for HTTP POST, libcurl force a Content-Length: 0 even though the caller
> has set its own Content-Length header,

> * 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.

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-01-13