cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Cédric Deltheil <cedric_at_moodstocks.com>
Date: Sat, 11 Jan 2014 18:45:27 +0100

Hi all,

When performing a standard HTTP POST (w/o chunked encoding) with a custom
read function, a common mistake is to forget to explicitly set the POST size
via `CURLOPT_POSTFIELDSIZE`.

This results in libcurl sending a negative content length:

    Content-Length: -1

, which gives a bad request.

The question is: should we prevent libcurl to send the request by failing early?

IMHO that would be helpful for the caller to help him understand the misuse.

Before sending a patch, I was wondering if `CURLE_UPLOAD_FAILED` would be the
best error code to use there.

Any suggestion or remark?

Thanks!

Cédric

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