[Catalyst-commits] r7046 -
trunk/Catalyst-Engine-HTTP-Sprocket/lib/Catalyst/Engine/HTTP/Sprocket
andyg at dev.catalyst.perl.org
andyg at dev.catalyst.perl.org
Mon Oct 22 19:52:48 GMT 2007
Author: andyg
Date: 2007-10-22 19:52:48 +0100 (Mon, 22 Oct 2007)
New Revision: 7046
Modified:
trunk/Catalyst-Engine-HTTP-Sprocket/lib/Catalyst/Engine/HTTP/Sprocket/Server.pm
trunk/Catalyst-Engine-HTTP-Sprocket/lib/Catalyst/Engine/HTTP/Sprocket/Worker.pm
Log:
Let Catalyst write the headers
Modified: trunk/Catalyst-Engine-HTTP-Sprocket/lib/Catalyst/Engine/HTTP/Sprocket/Server.pm
===================================================================
--- trunk/Catalyst-Engine-HTTP-Sprocket/lib/Catalyst/Engine/HTTP/Sprocket/Server.pm 2007-10-22 18:03:46 UTC (rev 7045)
+++ trunk/Catalyst-Engine-HTTP-Sprocket/lib/Catalyst/Engine/HTTP/Sprocket/Server.pm 2007-10-22 18:52:48 UTC (rev 7046)
@@ -126,6 +126,8 @@
# XXX: Static requests should be handled directly with AIO
+ # XXX: improve performance by parsing headers only in the child?
+
# If this connection is now handling body data, just pass it along
if ( my $id = $con->x->{body_mode} ) {
DEBUG && warn "[$id] Passed along " . length($req) . " bytes of body data\n";
@@ -240,7 +242,7 @@
DEBUG && warn "[$wheel_id] Sent $sent bytes\n";
}
- if ( $con->x->{sent} >= $con->x->{length} ) {
+ if ( $con->x->{seen_length} && $con->x->{sent} >= $con->x->{length} ) {
# All done sending the body, reset for the next request
DEBUG && warn "[$wheel_id] Done sending " . $con->x->{sent} . " bytes, resetting\n";
@@ -255,6 +257,12 @@
)
);
+ if ( $con->x->{body_mode} ) {
+ delete $con->x->{body_mode};
+
+ $self->{children}->{ $id }->set_stdin_filter( POE::Filter::Reference->new() );
+ }
+
# This child is free again
$self->{child_busy}->{ $wheel_id } = 0;
Modified: trunk/Catalyst-Engine-HTTP-Sprocket/lib/Catalyst/Engine/HTTP/Sprocket/Worker.pm
===================================================================
--- trunk/Catalyst-Engine-HTTP-Sprocket/lib/Catalyst/Engine/HTTP/Sprocket/Worker.pm 2007-10-22 18:03:46 UTC (rev 7045)
+++ trunk/Catalyst-Engine-HTTP-Sprocket/lib/Catalyst/Engine/HTTP/Sprocket/Worker.pm 2007-10-22 18:52:48 UTC (rev 7046)
@@ -6,7 +6,7 @@
use base qw(Catalyst::Engine::CGI);
use Data::Dump qw(dump);
-use HTTP::Response;
+use HTTP::Status qw(status_message);
use NEXT;
use POE::Filter::Reference;
@@ -41,8 +41,6 @@
my %copy_of_env = %ENV;
- #my $filter = POE::Filter::Reference->new();
-
while ( sysread STDIN, my $buf = '', 1024 ) {
my $req = $self->{filter}->get( [ $buf ] );
@@ -97,18 +95,13 @@
sub finalize_headers {
my ( $self, $c ) = @_;
+ my $protocol = $c->request->protocol;
+ my $status = $c->response->status;
+ my $message = status_message($status);
+
$self->NEXT::finalize_headers($c);
- # Remove the buffered header data so it's not sent during write()
- delete $self->{_header_buf};
-
- my $res = HTTP::Response->new(
- $c->res->status, undef, $c->res->headers
- );
-
- $res->protocol( $c->req->protocol );
-
- syswrite STDOUT, $res->as_string( "\x0D\x0A" );
+ syswrite STDOUT, "$protocol $status $message\x0D\x0A";
}
sub read_chunk {
More information about the Catalyst-commits
mailing list