$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)
}
}
+=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
$name = 'HTTP_' . $name
unless $name =~ m/\A(?:CONTENT_(?:LENGTH|TYPE)|COOKIE)\z/;
if ( exists $ENV{$name} ) {
- $ENV{$name} .= "; $value";
+ $ENV{$name} .= ", $value";
}
else {
$ENV{$name} = $value;
sub _socket_data {
my ( $self, $handle ) = @_;
- my $remote_sockaddr = getpeername($handle);
- my ( undef, $iaddr ) = sockaddr_in($remote_sockaddr);
- my $local_sockaddr = getsockname($handle);
+ my $remote_sockaddr = getpeername($handle);
+ my ( undef, $iaddr ) = $remote_sockaddr
+ ? sockaddr_in($remote_sockaddr)
+ : (undef, undef);
+
+ my $local_sockaddr = getsockname($handle);
my ( undef, $localiaddr ) = sockaddr_in($local_sockaddr);
+ # This mess is necessary to keep IE from crashing the server
my $data = {
- peername => gethostbyaddr( $iaddr, AF_INET ) || "localhost",
- peeraddr => inet_ntoa($iaddr) || "127.0.0.1",
- localname => gethostbyaddr( $localiaddr, AF_INET ) || "localhost",
- localaddr => inet_ntoa($localiaddr) || "127.0.0.1",
+ peername => $iaddr
+ ? ( gethostbyaddr( $iaddr, AF_INET ) || 'localhost' )
+ : 'localhost',
+ peeraddr => $iaddr
+ ? ( inet_ntoa($iaddr) || '127.0.0.1' )
+ : '127.0.0.1',
+ localname => gethostbyaddr( $localiaddr, AF_INET ) || 'localhost',
+ localaddr => inet_ntoa($localiaddr) || '127.0.0.1',
};
return $data;