I do some testing with HTTP::Daemon:
use HTTP::Daemon;
use HTTP::Status;
my $d = HTTP::Daemon->new || die;
print "Please contact me at: <URL:", $d->url, ">\n";
while (my $c = $d->accept) {
while (my $r = $c->get_request) {
if ($r->method eq 'GET') {
# do some action (about 10s)
}
else {
$c->send_error(RC_FORBIDDEN)
}
}
$c->close;
undef($c);
}
It works fine, but if I do more request within 10s,开发者_如何学运维 the requests gets queued (I get all requests through $d->accept)
What I want is the following: if a client starts a request, no other should be queued.
I tried with the Listen option, but without success.Any suggestions?
HTTP::Daemon doesn't fork for you, and explicitely tells you so in its documentation.
This HTTP daemon does not fork(2) for you. Your application, i.e. the user of the "HTTP::Daemon" is responsible for forking if that is desirable. Also note that the user is responsible for generating responses that conform to the HTTP/1.1 protocol.
If your answering takes too long, fork to answer. Or use another module.
you have one thread here; it can either handle the first request or handle the next one to come in. You can't deal with new requests until control goes back to accept.
精彩评论