forked from miyagawa/Starman
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a test for 500 from requests without CR
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Plack::Test; | ||
use HTTP::Request; | ||
use Test::More; | ||
|
||
{ | ||
|
||
package Starman::Server; | ||
|
||
# override so we can mangle the HTTP request | ||
use subs 'sysread'; | ||
|
||
*Starman::Server::sysread = sub { | ||
my $read = CORE::sysread( $_[0], $_[1], $_[2] ); | ||
$_[1] =~ s/\r\n/\n/g; | ||
|
||
return $read; | ||
}; | ||
|
||
} | ||
|
||
$Plack::Test::Impl = "Server"; | ||
$ENV{PLACK_SERVER} = 'Starman'; | ||
|
||
my $app = sub { | ||
my $env = shift; | ||
return sub { | ||
my $response = shift; | ||
my $writer = $response->( [ 200, [ 'Content-Type', 'text/plain' ] ] ); | ||
} | ||
}; | ||
|
||
test_psgi $app, sub { | ||
my $cb = shift; | ||
|
||
my $req = HTTP::Request->new( GET => "http://localhost/" ); | ||
|
||
my $res = $cb->($req); | ||
is $res->code, 200; | ||
|
||
}; | ||
|
||
done_testing; |