cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: HTTP Put and Content-Length header

From: Daniel Stenberg <daniel_at_haxx.se>
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!

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