use bytes;
use base 'Class::Accessor::Fast';
-our $VERSION = '1.1';
-
use Carp;
use HTTP::Response;
use IO::Handle;
__PACKAGE__->mk_accessors(qw[ environment request stdin stdout stderr ]);
# old typo
+
=begin Pod::Coverage
enviroment
$uri->port(80) unless $uri->port;
$uri->host_port($host) unless !$host || ( $host eq $uri->host_port );
+ # Get it before canonicalized so REQUEST_URI can be as raw as possible
+ my $request_uri = $uri->path_query;
+
$uri = $uri->canonical;
my $environment = {
SERVER_NAME => $uri->host,
SERVER_PORT => $uri->port,
SERVER_PROTOCOL => $request->protocol || 'HTTP/1.1',
- SERVER_SOFTWARE => "HTTP-Request-AsCGI/$VERSION",
+ SERVER_SOFTWARE => 'HTTP-Request-AsCGI/' . our $VERSION,
REMOTE_ADDR => '127.0.0.1',
REMOTE_HOST => 'localhost',
REMOTE_PORT => int( rand(64000) + 1000 ), # not in RFC 3875
- REQUEST_URI => $uri->path_query, # not in RFC 3875
+ REQUEST_URI => $request_uri, # not in RFC 3875
REQUEST_METHOD => $request->method,
@_
};
{
no warnings 'uninitialized';
- %ENV = %ENV, %{ $self->environment };
+ %ENV = (%ENV, %{ $self->environment });
}
if ( $INC{'CGI.pm'} ) {
}
else {
- my $length = 0;
+ my $length = defined $response->content ? length( $response->content ) : 0;
while ( $self->stdout->read( my $buffer, 4096 ) ) {
$length += length($buffer);