Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#21 Duplicate Content-Length Header

mod_gzip-1.3.26.1a
open
nobody
None
5
2003-11-24
2003-11-24
Thomas Nolting
No

Hello,
we use Apache as a web server frontend for the IBM
WebSphere Application Server. To improve performance
we would like to compress the dynamically generated
content with mod_gzip.
Although the response times with mod_gzip are in the
average much better than without compression, we
found out that some applications perfom really poor. It
seems as if the requests would "hang" for a long time
and suddenly the content was flushed to the client.
Without mod_gzip the same applications respond pretty
fast.
It turned out that under some circumstances,
WebSphere includes a "content-length" HTTP-Header in
the response. It is the number of bytes before
compression. It seems that mod_gzip does not recognize
this header (low cases!!) and does not replace it.
Instead it includes another HTTP-Header "Content-
Length" (the number of bytes after compression).

The browser (we tested with MS Internet Explorer)
seems to interpret the first header ("content-length") -
generally less bytes than the actual response has - and
waits for the rest of the bytes until it is timed out.

Correct me if I'm wrong, but as far as I know the HTTP
protocol does not specify that HTTP-Headers have to be
written in upper, lower or mixed case. Accordingly
the "content-length"-Header should be encountered and
replaced.
Since mod_gzip uses the Apache API (ap_table_set())
this could also be a bug in the Apache API.

Best regards,
Thomas Nolting

Discussion

  • atze
    atze
    2004-11-22

    Logged In: YES
    user_id=1078035

    the bug is in mod_gzip.

    the code checks for the first character and if it fits it checks the whole
    token. the token-check is case insensitive - the character check is not!

    so just add some lowercase-character checks to the code and it works
    fine :)
    example:
    change this line: else if ( lbuf[0] == 'C' )
    to that: else if ( lbuf[0] == 'C' || lbuf[0] == 'c')

    here is the thing that does not get called if your app delivers a lowercase
    'content-length' token:

    {
    if ( mod_gzip_strnicmp(lbuf,"Content-
    Encoding:",17)==0)
    {
    ce_seen = 1;
    }
    else if ( mod_gzip_strnicmp(lbuf,"Content-
    Length:",15)==0)
    {
    ok_to_send = 0;
    }
    }