httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Piotr Pawłow>
Subject [users@httpd] mod_deflate mangles 304 responses from PHP
Date Sat, 07 May 2005 13:46:59 GMT

I have a problem with mod_deflate. If deflate is enabled, 304 responses from
PHP are returned with some binary body data, which is in violation of
RFC2616 (304 response must have no body), and breaks pipelining/keep-alive.

Here is a simple test:

Reload the page in a browser with some sniffer running, or just telnet to
the server and send Accept-Encoding and If-Modified headers like this:

$ telnet 80
Connected to
Escape character is '^]'.
GET /tmp/ifmodifiedtest.php HTTP/1.1
Accept-Encoding: gzip,deflate
If-Modified-Since: Sat, 14 Apr 2001 20:00:36 GMT

Binary data after the response may not be visible in a shell, so it may be a
good idea to redirect the output to a file.

I tested it with Apache 2.0.(53|54) and PHP 5.0.(3|4) (mod_php, compiled as
a handler). More details about my system:

To work-around this problem, I added a simple check to mod_deflate.c:
            return ap_pass_brigade(f->next, bb);

        /* don't work on responses which must have no content */
        if (r->status == HTTP_NOT_MODIFIED || r->status == HTTP_NO_CONTENT)
            return ap_pass_brigade(f->next, bb);

        /* some browsers might have problems, so set no-gzip
         * (with browsermatch) for them
        if (apr_table_get(r->subprocess_env, "no-gzip")) {

It seems to work, as seen here:
(same test script, different server)
I don't know if this is a proper solution though.

Is it a known issue? Anyone else experiencing this problem?

 Piotr Pawłow

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message