hardburn has asked for the wisdom of the Perl Monks concerning the following question:

I've been trying to use Apache::GzipChain on my web server. Here is the configuration options I'm using httpd.conf:

<Directory "/path/to/dir"> AddHandler perl-script .cgi PerlHandler Apache::OutputChain Apache::GzipChain Apache::Registry allow from all PerlSendHeader On # Other stuff </Directory>

When I tried to access the front page with IE, the browser simply stoped. No error message, just stoped. So I tried connecting to the server via telnet like this:

$ telnet www.example.com 80 Trying 0.0.0.0... Connected to www.example.com. Escape character is '^]'. GET / HTTP/1.1 Host: example.com

And the response:

HTTP/1.1 200 OK Date: Fri, 13 Jun 2003 03:41:25 GMT Server: Apache/1.3.27 (Unix) Transfer-Encoding: chunked Content-Type: text/html fa1 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -- Rest of response unimportant --

My pages are generated from HTML::Template files, and they do have a valid DOCTYPE at the top, on the first line, with the second line starting the PUBLIC section. As you can see above, the first line is being cut off. I tried adding a blank line at the top in the template, but the behavior with IE remained (though a new telnet connect confirmed that the full DOCTYPE was being sent). Taking out the Apache::GzipChain in the chain caused it to work properly again.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Apache::GzipChain not sending first line of data
by Arguile (Hermit) on Jun 13, 2003 at 05:30 UTC

    My first instinct — on lines from the top of the response body being missing — would be a header problem. Does your error_log have anything to say about the issue?

    I'm not sure if Apache::GzipChain is actually the culprit. The reason I say this is twofold; the Vary header is missing, and the main handler won’t even have registered itself called like that from telnet. The Vary header is a list of factors used in content negotiation: Apache::GzipChain should always add ‘Accept-Encoding’ to the Vary header if it’s listed in the output chain in the conf. As for running, it even won’t register itself with Apache::OutputChain unless ‘gzip’ is found in the Accept-Encoding header.

    Here are a few suggestion to try (in no overly particular order):

    • Check your error_log.
    • Try with Apache::PassHTML instead of Apache::Registry as the last module in the chain, and point it at a static html document. This should tell you if Apache::GzipChain is working properly by itself. To test this easily with telnet, add PerlSetVar GzipForce On in that directory container (that var bypasses the normal negotiation). You should see the proper headers, including Content-Encoding, followed by a bunch of garbage (the gzipped output).
    • Update to the current versions off all the modules in the chain; if possible.
    • Out of curiosity, try running with PerlSetHeader Off
    • Make sure your Apache::Registry scripts play by the proper header rules outlined here.
    • Make sure you don’t make any calls to $r->http_send_header.

    That’s about all I can think of (I haven’t actually used Apache::OutputChain for quite a while, I’m an Apache::Filter user now ;). Hopefully one of those suggestion works, or at least leads you in the proper direction.

Re: Apache::GzipChain not sending first line of data
by perrin (Chancellor) on Jun 13, 2003 at 04:32 UTC
    I don't have any hands-on experience with GzipChain, but have you looked at this document on the mod_perl site yet?