keep-alives with HTTP 1.0

keep-alives with HTTP 1.0

am 08.12.2008 20:20:51 von Bill Moseley

Apache/2.2.9 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.0

Is there something special I need to do to allow keep-alive responses
for HTTP 1.0 requests?

If I setup a simple httpd.conf with a DocumentRoot and a simple
mod_perl handler I get keep-alive connections as I expect with HTTP
1.1, but with 1.0 I only get keep-alive connections with the static
content.

The issue is I have Perlbal in front of mod_perl and it always sends a
1.0 header to the back end so the mod_perl requests are not kept
alive.


Here's an example:

$ cat httpd.conf


LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so


LoadModule mime_module /usr/lib/apache2/modules/mod_mime.so


ErrorLog httpd_test.log
PidFile httpd_test.pid
TypesConfig /etc/mime.types
ServerName localhost
Listen 127.0.0.1:10000

KeepAlive On
KeepAliveTimeout 20000
MaxKeepAliveRequests 0
DocumentRoot /var/www


package Foo;
use Apache2::RequestIO ();
use Apache2::RequestRec ();

sub handler {
my $r = shift;
$r->print( 'This is content' );
$r->status( 200 );
$r->content_type( 'text/plain' );
$r->rflush;
return Apache2::Const::OK;
}




SetHandler modperl
PerlResponseHandler Foo




Start the server:

$ /usr/sbin/apache2 -d $HOME -f httpd.conf -k start


Fetch static content with HTTP 1.0 and get a keep-alive connection.

$ telnet localhost 10000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /index.html HTTP/1.0
Host: localhost:10000
Keep-Alive: 300
Connection: keep-alive


HTTP/1.1 200 OK
Date: Mon, 08 Dec 2008 18:48:38 GMT
Server: Apache/2.2.9 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.0
Last-Modified: Sun, 17 Aug 2008 02:33:33 GMT
ETag: "e0049-2d-4549eae51b940"
Accept-Ranges: bytes
Content-Length: 45
Keep-Alive: timeout=20000
Connection: Keep-Alive
Content-Type: text/html

It works!




Fetch mod_perl response with 1.0 and no keep-alive connection:

$ telnet localhost 10000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /foo HTTP/1.0
Host: localhost:10000
Keep-Alive: 300
Connection: keep-alive

HTTP/1.1 200 OK
Date: Mon, 08 Dec 2008 18:49:26 GMT
Server: Apache/2.2.9 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.0
Connection: close
Content-Type: text/plain


Fetch mod_perl with http 1.1 and do get the keep-alive connection.

$ telnet localhost 10000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /foo HTTP/1.1
Host: localhost:10000
Keep-Alive: 300
Connection: keep-alive

HTTP/1.1 200 OK
Date: Mon, 08 Dec 2008 18:50:23 GMT
Server: Apache/2.2.9 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.0
Keep-Alive: timeout=20000
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/plain

f
This is content
0




--
Bill Moseley
moseley@hank.org
Sent from my iMutt

Re: keep-alives with HTTP 1.0

am 09.12.2008 20:33:52 von Perrin Harkins

On Mon, Dec 8, 2008 at 2:20 PM, Bill Moseley wrote:
> Is there something special I need to do to allow keep-alive responses
> for HTTP 1.0 requests?

Not sure, but there's some info in Apache2::Connection about how it
determines Keep-Alive and how to check if a connection has it. More
in Apach2::RequestRec too.

- Perrin

Re: keep-alives with HTTP 1.0

am 09.12.2008 23:15:11 von Bill Moseley

On Tue, Dec 09, 2008 at 02:33:52PM -0500, Perrin Harkins wrote:
> On Mon, Dec 8, 2008 at 2:20 PM, Bill Moseley wrote:
> > Is there something special I need to do to allow keep-alive responses
> > for HTTP 1.0 requests?
>
> Not sure, but there's some info in Apache2::Connection about how it
> determines Keep-Alive and how to check if a connection has it. More
> in Apach2::RequestRec too.

Need a content-length header for it to work with HTTP 1.0.
The root of the problem was I was using mod_deflate and it was not
returning a content-length, and thus I was not seeing keep-alive
connections.

Thanks,

--
Bill Moseley
moseley@hank.org
Sent from my iMutt