tests:webserver: move parsing of request to its own function.
(Prepare for really parsing the request...) Michael
This commit is contained in:
parent
8f8f99098e
commit
afacc3d80b
@ -75,6 +75,23 @@ sub REAPER {
|
|||||||
$SIG{CHLD} = \&REAPER;
|
$SIG{CHLD} = \&REAPER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub parse_request($) {
|
||||||
|
my $client = shift;
|
||||||
|
|
||||||
|
my $request = "";
|
||||||
|
while (my $request_line = <$client>) {
|
||||||
|
$request .= $request_line;
|
||||||
|
last if ($request_line eq $EOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
logmsg "request:\n" .
|
||||||
|
"------------------------------\n" .
|
||||||
|
"$request" .
|
||||||
|
"------------------------------";
|
||||||
|
|
||||||
|
return $request;
|
||||||
|
}
|
||||||
|
|
||||||
sub child_action($) {
|
sub child_action($) {
|
||||||
my $client = shift;
|
my $client = shift;
|
||||||
my $client_ip = shift;
|
my $client_ip = shift;
|
||||||
@ -90,16 +107,7 @@ sub child_action($) {
|
|||||||
$fortune =~ s/\n/$EOL/g;
|
$fortune =~ s/\n/$EOL/g;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $request = "";
|
my $request = parse_request($client);
|
||||||
while (my $request_line = <$client>) {
|
|
||||||
$request .= $request_line;
|
|
||||||
last if ($request_line eq $EOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
logmsg "request:\n" .
|
|
||||||
"------------------------------\n" .
|
|
||||||
"$request" .
|
|
||||||
"------------------------------";
|
|
||||||
|
|
||||||
print $client "HTTP/1.0 200 OK$EOL";
|
print $client "HTTP/1.0 200 OK$EOL";
|
||||||
print $client "Server: Tinyproxy-Test-Web-Server/$VERSION$EOL";
|
print $client "Server: Tinyproxy-Test-Web-Server/$VERSION$EOL";
|
||||||
|
Loading…
Reference in New Issue
Block a user