cURL / Mailing Lists / curl-library / Single Mail


Re: HTTP Put and Content-Length header

From: Daniel Stenberg <>
Date: Tue, 9 Aug 2011 15:09:09 +0200 (CEST)

On Tue, 9 Aug 2011, Alex Bligh wrote:

> I am doing an HTTP PUT with a binary file to a server which requires
> a non-zero Content-Length to be set.
> I have tried setting CURLOPT_INFILESIZE_LARGE to the length of the the file.

What happened then? Did you make sure you passed on a size that was curl_off_t
sized - like perhaps typecasted ?

> I have tried setting CURLOUT_IGNORE_CONTENT_LENGTH to 0

This option is about how to deal with a _received_ Content-Length: header.

> I have tried manually adding a Content-Length: header.

That works for the request but won't tell libcurl about what size to expect.

> curl -X PUT -T [file] -D - [url]
> Adding --libcurl put.c suggests that what curl is doing is providing
> it's own function to supply the headers (perhaps I am reading this wrong).

That code uses CURLOPT_INFILESIZE_LARGE, doesn't it?

> The behaviour I expected was for curl to work the content length out from
> CURLOPT_INFILESIZE_LARGE. Perhaps that was naive?

No, it was correct!

List admin:
Received on 2011-08-09