Created
June 10, 2011 16:26
-
-
Save miyagawa/1019207 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# It is valid for an HTTP header to span multiple lines, as long as the continuation lines start with | |
# at least one space. This should be taken into account when parsing headers. | |
use Test::More 'no_plan'; | |
use CGI::Application::Emulate::PSGI; | |
use CGI::Application; | |
use HTTP::Message::PSGI qw(req_to_psgi); | |
use HTTP::Request; | |
my $env = req_to_psgi( HTTP::Request->new(GET => "/") ); | |
{ | |
my $psgi_app = CGI::Application::Emulate::PSGI->handler(sub { | |
my $webapp = CGI::Application->new; | |
$webapp->header_add( -zoo => "single-line header" ); | |
$webapp->run(); | |
}); | |
my ($out) = $psgi_app->($env); | |
my ($status,$headers) = @$out; | |
my %headers = @$headers; | |
is($status,200, "got 200 status"); | |
like($headers{Zoo}, qr{single}, "Zoo matches 'single'"); | |
like($headers{"Content-Type"}, qr{text/html}, "header header value matches text/html"); | |
} | |
{ | |
my $psgi_app = CGI::Application::Emulate::PSGI->handler(sub { | |
my $webapp = CGI::Application->new; | |
$webapp->header_add( -foo => "multi-line: header\n fools: you?" ); | |
$webapp->run(); | |
}); | |
my ($out) = $psgi_app->($env); | |
my ($status,$headers) = @$out; | |
my %headers = @$headers; | |
is($status,200, "got 200 status"); | |
like($headers{Zoo}, qr{fools: Your}, "Zoo header value matches 'fools: you'"); | |
like($headers{"Content-Type"}, qr{text/html}, "header header value matches text/html"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment