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

Hi,

I have an apache 2.2.16 with mod_perl 2.0.4 all built from source running on Ubuntu 10.04.

KeepAlive is On in the apache-config.

When using a http 1.1 client everything works as expected (connections are reused), but when using an http 1.0 client that sets a "Connection: Keep-Alive" header (e.g. wget) I've noticed something strange:

For static content connections are reused, but for all requests that are handled by mod_perl the connection is closed by the server (i.e. mod_perl/apache) after the first http-request (I have traced the tcp-level with wireshark).

Why is that?

Is there a way to configure mod_perl so that a keep-alive header is honored when using http 1.0?

Many thanks!

Replies are listed 'Best First'.
Re: http 1.0 keep-alive and mod_perl
by Anonymous Monk on Oct 12, 2010 at 02:52 UTC
    Why is that?

    A bunch of reasons, one of which is http 1.0 did not support keep-alive

    HTTP 1.0, by default, does not support persistent connections. ...While some implementations HTTP/1.0 supports persistence through the use of a keep-alive, there is no official specification for how the keep-alive operates.

    Is there a way to configure mod_perl so that a keep-alive header is honored when using http 1.0?

    Probably maybe :)

      While some implementations HTTP/1.0 supports persistence
      Evidently apache is one of those implementations as it works with static content.

      I simply would like to understand why there is a difference between static content and mod_perl content here.

        I simply would like to understand why there is a difference between static content and mod_perl content here.

        Great, please let us know when you figure it out :)

Re: http 1.0 keep-alive and mod_perl
by aquarium (Curate) on Oct 12, 2010 at 05:45 UTC
    most live apache configs do the right thing to fudge keep-alive in http 1.0 if possible, but sometimes it's not possible depending on some intricate factors.
    and sometimes the overarching factor is that a CGI program automatically sends some headers (clues) to the web server or even the browser clues in on the content being CGI/dynamic and does certain things..ending up in connection closing.
    i'd investigate the http1.0 kruft in apache docs, and maybe even try setting a multi-part header at the start in your perl script.
    the hardest line to type correctly is: stty erase ^H
      the overarching factor is that a CGI program automatically sends some headers (clues) to the web server
      This does not make any sense at all to me - could you please elaborate?

      try setting a multi-part header at the start in your perl script
      Could you please explain why this would play a role?