Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I am trying to use HTTP::Daemon as a mini-webserver (as part of a larger script). If a client makes an HTTP GET request (using wget), everything works fine. However, if I kill the client (just after the web server receives the request), when the HTTP::Daemon calls send_response, the entire process dies! I tried stepping into Daemon.pm to find where it kills the process. In Daemon::send_basic_header, send_status_line works fine (which supposedly sends status to the client) but the next line kills my entire process
sub send_basic_header { my $self = shift; ... $self->send_status_line(@_) #works print $self "Date: ", time2str(time), $CRLF #DIES HERE ... }
Can anyone help me? thanks, Michael

Replies are listed 'Best First'.
Re: HTTP::Daemon kills process
by moritz (Cardinal) on May 31, 2007 at 18:19 UTC
    That's probably not "best practice", but you could just enclose the failing call to send_basic_header in a try {...} block (and check $@ afterwards), then at least not your whole app will die.
      Thanks for your help. Like you said, I tried putting a try block around the send_basic_header code. Unfortunately, the $@ is '' and the process still dies..
Re: HTTP::Daemon kills process
by Khen1950fx (Canon) on May 31, 2007 at 18:36 UTC