cURL / Mailing Lists / curl-library / Single Mail


Re: Content-Length Vs Chunked Transfer Encoding

From: Dan Fandrich <>
Date: Tue, 8 Jul 2014 17:25:32 +0200

On Mon, Jul 07, 2014 at 05:48:46PM -0400, Eric Fortin wrote:
> > On Jun 26, 2014, at 7:19 AM, Sandeep Sastry <> wrote:
> > Though there are some existing discussion related to the topic "Content-Length Vs Chunked Transfer Encoding" on various non-curl sites, I wanted to understand how it works with libcurl.
> > I am using curl in my client application and as part of the application, I show progress bar for upload and download activity. The old server used to send Content-Length header in the response to GET requests, consistently.
> > But now the new server, does not send Content-Length, but sends Chunked Transfer Encoding. This is breaking my progress functionality as I always get "0" for total download size.
> > Is there a way for me to still get the progress bar going, though the server does not send Content-Length? Because when contacted the server guys, they told me they would no more be using Content-Length.
> You might be able to do a HEAD request to get the file size and then infer the progress based on the data you received while receiving the GET response.

If a GET response doesn't include a Content-Length, it's extremely unlikely
that a HEAD request would. Usually, a chunked response is used when the
complete length simply isn't known ahead of time.

>>> Dan
List admin:
Received on 2014-07-08