cURL / Mailing Lists / curl-library / Single Mail


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

From: CÚdric Deltheil <>
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

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?



List admin:
Received on 2014-01-11