authors cleanup
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / CGI.pm
index 2ee2e01..ca86d79 100644 (file)
@@ -42,7 +42,8 @@ sub finalize_headers {
 
     $c->response->header( Status => $c->response->status );
 
-    print $c->response->headers->as_string("\015\012") . "\015\012";
+    $self->{_header_buf} 
+        = $c->response->headers->as_string("\015\012") . "\015\012";
 }
 
 =head2 $self->prepare_connection($c)
@@ -142,10 +143,10 @@ sub prepare_path {
     # Using URI directly is way too slow, so we construct the URLs manually
     my $uri_class = "URI::$scheme";
     
-    # HTTP_HOST will include the port even if it's 80
-    $host =~ s/:80$//;
+    # HTTP_HOST will include the port even if it's 80/443
+    $host =~ s/:(?:80|443)$//;
     
-    if ( $port != 80 && $host !~ /:/ ) {
+    if ( $port !~ /^(?:80|443)$/ && $host !~ /:/ ) {
         $host .= ":$port";
     }
     
@@ -207,6 +208,23 @@ sub prepare_write {
     $self->NEXT::prepare_write($c);
 }
 
+=head2 $self->write($c, $buffer)
+
+Writes the buffer to the client.
+
+=cut
+
+sub write {
+    my ( $self, $c, $buffer ) = @_;
+
+    # Prepend the headers if they have not yet been sent
+    if ( my $headers = delete $self->{_header_buf} ) {
+        $buffer = $headers . $buffer;
+    }
+    
+    return $self->NEXT::write( $c, $buffer );
+}
+
 =head2 $self->read_chunk($c, $buffer, $length)
 
 =cut
@@ -221,15 +239,11 @@ sub run { shift; shift->handle_request(@_) }
 
 =head1 SEE ALSO
 
-L<Catalyst> L<Catalyst::Engine>.
+L<Catalyst>, L<Catalyst::Engine>
 
 =head1 AUTHORS
 
-Sebastian Riedel, <sri@cpan.org>
-
-Christian Hansen, <ch@ngmedia.com>
-
-Andy Grundman, <andy@hybridized.org>
+Catalyst Contributors, see Catalyst.pm
 
 =head1 COPYRIGHT