cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: content-encoding: gzip

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 12 May 2003 13:08:40 -0700

On Mon, May 12, 2003 at 08:29:17PM +0200, David Remahl wrote:
> Hi list! (first poster; searched archives and google for hours but
> didn't find anything; sorry if I missed something)

You just missed the late-breaking news of cURL gzip support. Two of us
implemented it simultaneously about two weeks ago. It's in CVS.

> I am making an application that needs to accept gzipped gzipped data.
> The server compresses the data if I send Accept-encoding: gzip,
> equivalent to the following client app command line:
>
> curl --header 'accept-encoding: gzip' http://localhost/path

The syntax for the command-line client is
'curl --compressed http://localhost/path'

> The server responds, as expected with something like this:
>
> HTTP/1.1 200 OK
> Date: Mon, 12 May 2003 18:07:11 GMT
> Content-Type: application/x-whatever
> Content-Length: 129
> Content-Encoding: gzip
>
> <gzipped data>
>
> From reading the libcurl source, I find that handling of
> Content-Encoding: gzip is currently not implemented
> (http_chunks.c:192). Because of this, my problem is to find a good way
> to decompress the gzip stream.
>
> I think it must be possible to use zlib for this, but the gzip oriented
> functions in zlib are all file oriented. Previously, it was my
> understanding that inflate() would handle gzip, since it is basically
> the same algorithm as deflate / zip. That doesn't seem to be the case,
> since I get a BAD_DATA error from zlib when I ask it to inflate the
> gzip content.

gzip does indeed use the zlib deflate algorithm, but prepends its own header.
You just need to strip off the header and feed it to zlib.

> I have looked "everywhere" for an implementation of a program that
> inflates a gzip stream, but failed. Does anyone have a solution (except
> for forking a gzip process and pipe the stream to, which would be
> rather wasteful). Is inflate really the solution? In that case, why
> isn't gzip implemented in libcurl?

I guess nobody got around to doing it. It was a fairly small change to
the deflate code.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com
Received on 2003-05-12