You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Sai Jai Ganesh Gurubaran <sg...@cordys.com> on 2007/02/01 12:12:00 UTC

How to inflate a zipped content inside a module

Hi All,

            We have developed an output filter that gathers the response
data on to a local buffer for further processing.

It is working fine.

The issue we have is that some time the data comes in a compressed
format.

Is there any way to inflate the content within the filter (stored in the
local buffer only) so that our processing goes on smooth?

(The original content is no way to be modified)

Regards,

Ganesh


***********************************************************************
The information in this message is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this 
message by anyone else is unauthorized. If you are not the 
intended recipient, any disclosure, copying, or distribution of the 
message, or any action or omission taken by you in reliance on 
it is prohibited and may be unlawful. Please immediately contact 
the sender if you have received this message in error. This email 
does not constitute any commitment from Cordys Holding BV or 
any of its subsidiaries except when expressly agreed in a written 
agreement between the intended recipient and 
Cordys Holding BV or its subsidiaries.
***********************************************************************



Re: How to inflate a zipped content inside a module

Posted by Alexander Farber <al...@gmail.com>.
Here is my Apache1-code for deflating. Maybe it helps you

static int
gzip_filter(request_rec *r, char *src, unsigned slen)
{
        char            *dst;
        z_stream        zstr;
        unsigned        dlen;

        zstr.zalloc     = gzip_alloc;
        zstr.zfree      = gzip_free;
        zstr.opaque     = r->pool;
        zstr.next_in    = src;
        zstr.avail_in   = slen;
        /* add 16 to MAX_WBITS to enforce gzip format */
        if (Z_OK != deflateInit2(&zstr, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
            MAX_WBITS + 16, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY)) {
                ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
                    "deflateInit2() for gzip-format failed: %s", zstr.msg);
                return HTTP_SERVICE_UNAVAILABLE;
        }

        dlen = deflateBound(&zstr, slen);
        /* allocate 12 more bytes as workaround for zlib version <= 1.2.3 */
#if ZLIB_VERNUM <= 0x1230
        dlen += 12;
#endif

        dst = ap_palloc(r->pool, dlen);

        zstr.next_out   = dst;
        zstr.avail_out  = dlen;
        if (Z_STREAM_END != deflate(&zstr, Z_FINISH)) {
                ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
                    "deflate() failed: %s", zstr.msg);
                return HTTP_SERVICE_UNAVAILABLE;
        }

        ap_set_content_length(r, zstr.total_out);
        ap_table_setn(r->headers_out, "Content-Encoding", "gzip");
        ap_send_http_header(r);

        if (ap_rwrite(dst, zstr.total_out, r) != zstr.total_out)
                ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
                    "ap_rwrite of response data (%u bytes) failed", dlen);

        if (Z_OK != deflateEnd(&zstr))
                ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
                    "deflateEnd() failed: %s", zstr.msg);

        return OK;
}

On 2/1/07, Sai Jai Ganesh Gurubaran <sg...@cordys.com> wrote:
> More information:
>         Apache (2.0.59) is working as a forward proxy on Linux.
>
>             We have developed an output filter that gathers the response
> data on to a local buffer for further processing.
>
> It is working fine.
>
> The issue we have is that some time the data comes in a compressed
> format.
>
> Is there any way to inflate the content within the filter (stored in the
> local buffer only) so that our processing goes on smooth?
>
> (The original content is no way to be modified)



-- 
http://preferans.de

RE: How to inflate a zipped content inside a module

Posted by Sai Jai Ganesh Gurubaran <sg...@cordys.com>.
More information:
	Apache (2.0.59) is working as a forward proxy on Linux.


-----Original Message-----
From: Sai Jai Ganesh Gurubaran 
Sent: Thursday, February 01, 2007 4:42 PM
To: modules-dev@httpd.apache.org
Subject: How to inflate a zipped content inside a module

Hi All,

            We have developed an output filter that gathers the response
data on to a local buffer for further processing.

It is working fine.

The issue we have is that some time the data comes in a compressed
format.

Is there any way to inflate the content within the filter (stored in the
local buffer only) so that our processing goes on smooth?

(The original content is no way to be modified)

Regards,

Ganesh


***********************************************************************
The information in this message is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this 
message by anyone else is unauthorized. If you are not the 
intended recipient, any disclosure, copying, or distribution of the 
message, or any action or omission taken by you in reliance on 
it is prohibited and may be unlawful. Please immediately contact 
the sender if you have received this message in error. This email 
does not constitute any commitment from Cordys Holding BV or 
any of its subsidiaries except when expressly agreed in a written 
agreement between the intended recipient and 
Cordys Holding BV or its subsidiaries.
***********************************************************************