Catalyst-Engine-HTTP-Prefork
view release on metacpan or search on metacpan
lib/Catalyst/Engine/HTTP/Prefork.pm view on Meta::CPAN
SERVER_PORT => $self->{server}->{port}->[0],
SERVER_PROTOCOL => $proto,
%{ $self->{env} },
);
# Add headers
my $headers = $h->getHeaders();
$self->{client}->{headers} = $headers;
# prepare_connection and prepare_path need a few headers in %ENV
$ENV{HTTP_X_FORWARDED_FOR} = $headers->{'X-Forwarded-For'}
if $headers->{'X-Forwarded-For'};
$ENV{HTTP_X_FORWARDED_HOST} = $headers->{'X-Forwarded-Host'}
if $headers->{'X-Forwarded-Host'};
# Determine whether we will keep the connection open after the request
my $connection = $headers->{Connection};
if ( $proto && $proto eq 'HTTP/1.0' ) {
if ( $connection && $connection =~ /^keep-alive$/i ) {
# Keep-alive only with explicit header in HTTP/1.0
$self->{client}->{keepalive} = 1;
}
t/live_engine_request_headers.t view on Meta::CPAN
use HTTP::Request::Common;
{
my $creq;
my $request = GET( 'http://localhost/dump/request',
'User-Agent' => 'MyAgen/1.0',
'X-Whats-Cool' => 'Catalyst',
'X-Multiple' => [ 1 .. 5 ],
'X-Forwarded-Host' => 'frontend.server.com',
'X-Forwarded-For' => '192.168.1.1, 1.2.3.4',
);
ok( my $response = request($request), 'Request' );
ok( $response->is_success, 'Response Successful 2xx' );
is( $response->content_type, 'text/plain', 'Response Content-Type' );
like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
isa_ok( $creq, 'Catalyst::Request' );
isa_ok( $creq->headers, 'HTTP::Headers', 'Catalyst::Request->headers' );
is( $creq->header('X-Whats-Cool'), $request->header('X-Whats-Cool'), 'Catalyst::Request->header X-Whats-Cool' );
( run in 0.458 second using v1.01-cache-2.11-cpan-26ccb49234f )