cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Error 411 (Length Required) in post request with header, but header has Content-Length:

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Fri, 2 Sep 2011 18:12:22 -0700

On Fri, Sep 02, 2011 at 05:42:38PM +0300, Oleksiy wrote:
> I use this options:
>
> curl_easy_setopt(curl, CURLOPT_URL, urlUpload);
> curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
> curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buffer);
> curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header);
>
> It must be post request with header. And in header variable there is length
>
> ***
> char sizeStr[50];
> sprintf(sizeStr, "Content-Length: %d", body.length());

You should never need to specify the Content-Length header like this--libcurl
takes care of that as necessary. In this case, you probably want the
CURLOPT_POSTFIELDSIZE_LARGE option. Enable logging and you'll see exactly
what headers are being sent out.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-09-03