HTTPS-Handy

 view release on metacpan or  search on metacpan

lib/HTTPS/Handy.pm  view on Meta::CPAN

    # For 5.5.3 compatibility, use a simple object instead of
    # open my $fh, '<', \$scalar (which requires Perl 5.8+)
    my $input = HTTPS::Handy::Input->new($post_body);

    my %env = (
        'REQUEST_METHOD'  => $method,
        'PATH_INFO'       => $path,
        'QUERY_STRING'    => $query_string,
        'SERVER_NAME'     => $server_name,
        'SERVER_PORT'     => $env_port,
        'CONTENT_TYPE'    => $headers{'content-type'}   || '',
        'CONTENT_LENGTH'  => $content_length,
        'psgi.input'      => $input,
        'psgi.errors'     => \*STDERR,
        'psgi.url_scheme' => 'https',
        'psgi.ssl'        => 1,
        'psgix.tls_cipher'  => $client->cipher_name,
        'psgix.tls_resumed' => $client->was_resumed,
    );

    # Add HTTP_* headers

t/0004-server.t  view on Meta::CPAN

    return ($status, { %h }, defined $body ? $body : '');
}

# --- GET /hello -----------------------------------------------------------
my ($st, $hh, $bo);
($st, $hh, $bo) = https_req(path => '/hello');

like($st, qr{^HTTP/1\.0 200}, 'GET /hello: 200');
is($bo, 'Hello, Secure World!', 'GET /hello: body');
like(lc(defined $hh->{connection} ? $hh->{connection} : ''), qr{close}, 'Connection: close');
like($hh->{'content-type'}, qr{text/plain}, 'Content-Type');

# --- HTTPS-specific $env keys ----------------------------------------------
($st, $hh, $bo) = https_req(path => '/scheme');
is($bo, 'https', 'psgi.url_scheme is https');

($st, $hh, $bo) = https_req(path => '/ssl-flag');
is($bo, '1', 'psgi.ssl is 1');

# --- Request data mapped to $env -------------------------------------------
($st, $hh, $bo) = https_req(path => '/echo-method');



( run in 1.169 second using v1.01-cache-2.11-cpan-99fa8243a42 )