Moved IE workarounds to be only in the HTTP engine
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / HTTP.pm
index 881bf27..808cbca 100644 (file)
@@ -50,7 +50,12 @@ sub finalize_headers {
     $c->response->headers->date(time);
     $c->response->headers->header(
         Connection => $self->_keep_alive ? 'keep-alive' : 'close' );
-    $self->NEXT::finalize_headers($c);
+        
+    $c->response->header( Status => $c->response->status );
+        
+    # Avoid 'print() on closed filehandle Remote' warnings when using IE
+    print $c->response->headers->as_string("\015\012") if *STDOUT->opened();
+    print "\015\012" if *STDOUT->opened();
 }
 
 =head2 $self->finalize_read($c)
@@ -106,6 +111,19 @@ sub read_chunk {
     }
 }
 
+=head2 $self->write($c, $buffer)
+
+Writes the buffer to the client. Can only be called once for a request.
+
+=cut
+
+sub write {
+       # Avoid 'print() on closed filehandle Remote' warnings when using IE
+       return unless *STDOUT->opened();
+       
+       shift->NEXT::write( @_ );
+}
+
 =head2 run
 
 =cut
@@ -335,10 +353,11 @@ sub _parse_request_line {
 sub _socket_data {
     my ( $self, $handle ) = @_;
 
-    my $iaddr;
-    
     my $remote_sockaddr       = getpeername($handle);
-    ( undef, $iaddr )         = sockaddr_in($remote_sockaddr);
+    my ( undef, $iaddr )      = $remote_sockaddr 
+        ? sockaddr_in($remote_sockaddr) 
+        : (undef, undef);
+        
     my $local_sockaddr        = getsockname($handle);
     my ( undef, $localiaddr ) = sockaddr_in($local_sockaddr);