[Catalyst-commits] r6271 - / trunk/Catalyst-Runtime
trunk/Catalyst-Runtime/lib/Catalyst/Engine
zarquon at dev.catalyst.perl.org
zarquon at dev.catalyst.perl.org
Wed Apr 4 01:43:38 GMT 2007
Author: zarquon
Date: 2007-04-04 01:43:37 +0100 (Wed, 04 Apr 2007)
New Revision: 6271
Modified:
/
trunk/Catalyst-Runtime/
trunk/Catalyst-Runtime/Changes
trunk/Catalyst-Runtime/lib/Catalyst/Engine/HTTP.pm
Log:
r9771 at zaphod: kd | 2007-03-13 08:04:46 +1100
Property changes on:
___________________________________________________________________
Name: svk:merge
- 1b129c88-ebf4-0310-add9-f09427935aba:/local/catalyst:4278
1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst:9763
3b9770f9-e80c-0410-a7de-cd203d167417:/local/catalyst:3514
dd8ad9ea-0304-0410-a433-df5f223e7bc0:/local/Catalyst:6909
+ 1b129c88-ebf4-0310-add9-f09427935aba:/local/catalyst:4278
1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst:9771
3b9770f9-e80c-0410-a7de-cd203d167417:/local/catalyst:3514
dd8ad9ea-0304-0410-a433-df5f223e7bc0:/local/Catalyst:6909
Property changes on: trunk/Catalyst-Runtime
___________________________________________________________________
Name: svk:merge
- 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6145
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
+ 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
Modified: trunk/Catalyst-Runtime/Changes
===================================================================
--- trunk/Catalyst-Runtime/Changes 2007-04-04 00:43:01 UTC (rev 6270)
+++ trunk/Catalyst-Runtime/Changes 2007-04-04 00:43:37 UTC (rev 6271)
@@ -14,6 +14,7 @@
5.7007 2007-03-13 14:18:00
- Performance and stability improvements to the built-in HTTP server.
+ - Built-in server no longer supports -k (keep-alive).
- Don't ignore file uploads if form contains a text field with the same name.
(Carl Franks)
- Support restart_delay of 0 (for use in the POE engine).
Modified: trunk/Catalyst-Runtime/lib/Catalyst/Engine/HTTP.pm
===================================================================
--- trunk/Catalyst-Runtime/lib/Catalyst/Engine/HTTP.pm 2007-04-04 00:43:01 UTC (rev 6270)
+++ trunk/Catalyst-Runtime/lib/Catalyst/Engine/HTTP.pm 2007-04-04 00:43:37 UTC (rev 6271)
@@ -57,21 +57,9 @@
push @headers, "$protocol $status $message";
$c->response->headers->header( Date => HTTP::Date::time2str(time) );
+ $c->response->headers->header( Connection => 'close' );
$c->response->headers->header( Status => $status );
- # Should we keep the connection open?
- my $connection = $c->request->header('Connection');
- if ( $self->{options}->{keepalive}
- && $connection
- && $connection =~ /^keep-alive$/i
- ) {
- $c->response->headers->header( Connection => 'keep-alive' );
- $self->{_keepalive} = 1;
- }
- else {
- $c->response->headers->header( Connection => 'close' );
- }
-
push @headers, $c->response->headers->as_string("\x0D\x0A");
# Buffer the headers so they are sent with the first write() call
@@ -259,12 +247,20 @@
Remote->blocking(1);
- # Read until we see all headers
+ # Read until we see a newline
$self->{inputbuf} = '';
+
+ while (1) {
+ my $read = sysread Remote, my $buf, CHUNKSIZE;
- if ( !$self->_read_headers ) {
- # Error reading, give up
- next LISTEN;
+ if ( !$read ) {
+ DEBUG && warn "EOF or error: $!\n";
+ next LISTEN;
+ }
+
+ DEBUG && warn "Read $read bytes\n";
+ $self->{inputbuf} .= $buf;
+ last if $self->{inputbuf} =~ /(\x0D\x0A?|\x0A\x0D?)/s;
}
my ( $method, $uri, $protocol ) = $self->_parse_request_line;
@@ -359,81 +355,36 @@
%copy_of_env,
);
- # Initialize CGI environment
- local %ENV = (
- PATH_INFO => $path || '',
- QUERY_STRING => $query_string || '',
- REMOTE_ADDR => $sockdata->{peeraddr},
- REMOTE_HOST => $sockdata->{peername},
- REQUEST_METHOD => $method || '',
- SERVER_NAME => $sockdata->{localname},
- SERVER_PORT => $port,
- SERVER_PROTOCOL => "HTTP/$protocol",
- %copy_of_env,
- );
+ # Initialize CGI environment
+ local %ENV = (
+ PATH_INFO => $path || '',
+ QUERY_STRING => $query_string || '',
+ REMOTE_ADDR => $sockdata->{peeraddr},
+ REMOTE_HOST => $sockdata->{peername},
+ REQUEST_METHOD => $method || '',
+ SERVER_NAME => $sockdata->{localname},
+ SERVER_PORT => $port,
+ SERVER_PROTOCOL => "HTTP/$protocol",
+ %copy_of_env,
+ );
- # Parse headers
- if ( $protocol >= 1 ) {
- $self->_parse_headers;
- }
+ # Parse headers
+ if ( $protocol >= 1 ) {
+ $self->_parse_headers;
+ }
- # Pass flow control to Catalyst
- $class->handle_request;
+ # Pass flow control to Catalyst
+ $class->handle_request;
- DEBUG && warn "Request done\n";
+ DEBUG && warn "Request done\n";
- # Allow keepalive requests, this is a hack but we'll support it until
- # the next major release.
- if ( delete $self->{_keepalive} ) {
-
- DEBUG && warn "Reusing previous connection for keep-alive request\n";
-
- if ( $sel->can_read(1) ) {
- if ( !$self->_read_headers ) {
- # Error reading, give up
- last REQUEST;
- }
+ # XXX: We used to have a hack for keep-alive here but keep-alive
+ # has no place in a single-tasking server like this. Use HTTP::POE
+ # if you want keep-alive.
- ( $method, $uri, $protocol ) = $self->_parse_request_line;
-
- DEBUG && warn "Parsed request: $method $uri $protocol\n";
-
- # Force HTTP/1.0
- $protocol = '1.0';
-
- next REQUEST;
- }
-
- DEBUG && warn "No keep-alive request within 1 second\n";
- }
-
- last REQUEST;
- }
-
- DEBUG && warn "Closing connection\n";
-
close Remote;
}
-sub _read_headers {
- my $self = shift;
-
- while (1) {
- my $read = sysread Remote, my $buf, CHUNKSIZE;
-
- if ( !$read ) {
- DEBUG && warn "EOF or error: $!\n";
- return;
- }
-
- DEBUG && warn "Read $read bytes\n";
- $self->{inputbuf} .= $buf;
- last if $self->{inputbuf} =~ /(\x0D\x0A?\x0D\x0A?|\x0A\x0D?\x0A\x0D?)/s;
- }
-
- return 1;
-}
-
sub _parse_request_line {
my $self = shift;
More information about the Catalyst-commits
mailing list