FU: Some FastCGI fixes; FU::Util: utf8_decode & URI escaping
This commit is contained in:
parent
d9fba4e8d8
commit
90cfd66069
6 changed files with 146 additions and 33 deletions
39
t/fcgi.t
39
t/fcgi.t
|
|
@ -10,8 +10,8 @@ sub start {
|
|||
$f = FU::fcgi::new(fileno $local, 123);
|
||||
}
|
||||
|
||||
sub record($id, $type, $data) {
|
||||
my $pad = rand > 0.5 ? int rand(50) : 0;
|
||||
sub record($id, $type, $data, $pad=undef) {
|
||||
$pad //= rand > 0.5 ? int rand(50) : 0;
|
||||
my $msg = pack('CCnnCC', 1, $type, $id, length($data), $pad, 0) . $data . ("\0"x$pad);
|
||||
is $remote->syswrite($msg, length($msg)), length($msg);
|
||||
}
|
||||
|
|
@ -31,13 +31,19 @@ sub isrec($hdr, $par, $code=0) {
|
|||
}
|
||||
|
||||
sub isrecv($data) {
|
||||
is $remote->sysread(my $buf, length $data), length $data;
|
||||
my($buf, $off) = ('', 0);
|
||||
$off += $remote->sysread($buf, length($data) - $off, $off) while $off < length $data;
|
||||
is $buf, $data;
|
||||
}
|
||||
|
||||
|
||||
start;
|
||||
$remote->close;
|
||||
iserr -7;
|
||||
|
||||
start;
|
||||
begin;
|
||||
$remote->close;
|
||||
iserr -1;
|
||||
|
||||
start;
|
||||
|
|
@ -96,6 +102,8 @@ $f->print("Status: 200\r\n");
|
|||
$f->print("Something else");
|
||||
$f->flush;
|
||||
isrecv "\1\6\0\5\0\x1b\0\0"."Status: 200\r\nSomething else";
|
||||
isrecv "\1\6\0\5\0\0\0\0";
|
||||
isrecv "\1\3\0\5\0\x08\0\0"."\0\0\0\0\0\0\0\0";
|
||||
# Same connection:
|
||||
begin;
|
||||
record 1, 4, "\x00\x00\x06\x00HTTP_x\x00\x00";
|
||||
|
|
@ -159,4 +167,29 @@ record 1, 4, "\x0c\x05CONTENT_TYPEsomet";
|
|||
record 1, 2, "";
|
||||
isrec {'content-type','somet'}, {body => ''}, -6;
|
||||
|
||||
start;
|
||||
begin;
|
||||
record 1, 4, "\x0e\x05CONTENT_LENGTH65536";
|
||||
record 1, 4, '';
|
||||
if (!fork) {
|
||||
record 1, 5, 'A'x65535, 255;
|
||||
record 1, 5, 'B', 255;
|
||||
record 1, 5, '';
|
||||
exit;
|
||||
}
|
||||
isrec {'content-length',65536}, {body => ('A'x65535) . 'B'};
|
||||
if (!fork) {
|
||||
$f->print('a');
|
||||
$f->print('b');
|
||||
$f->print('c');
|
||||
$f->print('D' x 65536);
|
||||
$f->print('e');
|
||||
$f->flush;
|
||||
exit;
|
||||
}
|
||||
isrecv "\1\6\0\1\xff\xff\0\0".'abc'.('D'x65532);
|
||||
isrecv "\1\6\0\1\0\5\0\0".'DDDDe';
|
||||
isrecv "\1\6\0\1\0\0\0\0";
|
||||
isrecv "\1\3\0\1\0\x08\0\0"."\0\0\0\0\0\0\0\0";
|
||||
|
||||
done_testing;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue