cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Issues_Http_chunked_Method

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, 12 Sep 2012 21:13:26 +0200

On Wed, Sep 12, 2012 at 02:30:34PM +0530, karan tandel wrote:
>          We are using liburl to send Http Requests in our projects. Now when we
> are 
> requesting requests using
>  Http Get Method we are getting Http Response in its "CHUNKED" data format.
>
> So we are getting response like this,
>
> HTTP/1.0 200 OK\r\n
> connection:Keep-Alive\r\n
> Transfer-Encoding:Chunked\r\n
> Content-Type:video/h264\r\n
> \r\n
> 005340\r\n(Chunked-Data Length)
> ---Chunked Data--
> 01000\r\n
> --Chunked Data---
>
> We are not getting chunked data len "005340\r\n" in both our write data and
> header 
> function. We get only header response up to "Content-Type:video/h264\r\n \r\n"
> and in 
> data field response start directly from "--Chunked-Data---" field . We are not
> getting 
> this chunked dataLen "005340\r\n"  in response.
>
> Why is it happening? What is the procedure to get that chunked data length in
> our 
> response?

Chunked transfer-encoding is, as you might expect, part of the transfer
protocol and curl handles that transparently. The decoded data is passed
in to the write callback function. You can infer the size of the chunked
data section by the size of the data passed into the callback, but it's
not always going to be the same. I don't believe there's any way for
libcurl to pass that information to the application, nor any good reason
to, just as there's no good reason for the network layer to pass the
size of the TCP segments to the application.

You could do a CURLOPT_CONNECT_ONLY connection and then do the HTTP in
the application, but then you might as well use raw sockets. The
CURLOPT_DEBUGFUNCTION callback will probably also give it to you,
while processing the normal HTTP transaction. Why do you need access to
the chunk size, anyway?

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-09-12