changed pid stuff, made it work with rfc1867 posts and made it work better
on paths
This commit is contained in:
parent
b2daec2477
commit
69e82e7383
@ -18,7 +18,7 @@ listen(Server,SOMAXCONN) || die "listen: $!";
|
|||||||
|
|
||||||
logmsg "server started on port $port";
|
logmsg "server started on port $port";
|
||||||
|
|
||||||
open(PID, ">log/server.pid");
|
open(PID, ">.server.pid");
|
||||||
print PID $$;
|
print PID $$;
|
||||||
close(PID);
|
close(PID);
|
||||||
|
|
||||||
@ -45,6 +45,7 @@ for ( $waitedpid = 0;
|
|||||||
|
|
||||||
# this code is forked and run
|
# this code is forked and run
|
||||||
spawn sub {
|
spawn sub {
|
||||||
|
my ($request, $path, $ver, $left, $cl);
|
||||||
while(<STDIN>) {
|
while(<STDIN>) {
|
||||||
if($_ =~ /(GET|POST|HEAD) (.*) HTTP\/1.(\d)/) {
|
if($_ =~ /(GET|POST|HEAD) (.*) HTTP\/1.(\d)/) {
|
||||||
$request=$1;
|
$request=$1;
|
||||||
@ -54,15 +55,19 @@ for ( $waitedpid = 0;
|
|||||||
elsif($_ =~ /^Content-Length: (\d*)/) {
|
elsif($_ =~ /^Content-Length: (\d*)/) {
|
||||||
$cl=$1;
|
$cl=$1;
|
||||||
}
|
}
|
||||||
# print "RCV: $_";
|
|
||||||
|
|
||||||
push @headers, $_;
|
push @headers, $_;
|
||||||
|
|
||||||
if($left > 0) {
|
if($left > 0) {
|
||||||
$left -= length($_);
|
$left -= length($_);
|
||||||
|
if($left == 0) {
|
||||||
|
$left = -1; # just to force a loop break here
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
# print STDERR "RCV ($left): $_";
|
||||||
|
|
||||||
if(($_ eq "\r\n") or ($_ eq "")) {
|
if(!$left &&
|
||||||
|
($_ eq "\r\n") or ($_ eq "")) {
|
||||||
if($request eq "POST") {
|
if($request eq "POST") {
|
||||||
$left=$cl;
|
$left=$cl;
|
||||||
}
|
}
|
||||||
@ -80,7 +85,7 @@ for ( $waitedpid = 0;
|
|||||||
# test number that this server will use to know what
|
# test number that this server will use to know what
|
||||||
# contents to pass back to the client
|
# contents to pass back to the client
|
||||||
#
|
#
|
||||||
if($path =~ /^\/(\d*)/) {
|
if($path =~ /.*\/(\d*)/) {
|
||||||
$testnum=$1;
|
$testnum=$1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user