sub accept_messages { my $self = shift; unless ($self->{daemon}) { my ($localaddr, $localport) = split /:/, $self->{address}; $self->{daemon} = new HTTP::Daemon ( LocalAddr => $localaddr, LocalPort => $localport ); ref $self->{daemon} or $self->_debug("Could not create HTTP::Daemon $! $@", 3); $self->{daemon}->timeout($self->{timeout}) if $self->{timeout}; # normally timeout is 20 } local $SIG{PIPE} = sub { warn 'PIPE WHILE READING'; undef $self->{daemon}; }; CONNECTION: while (1) { my $conn = $self->{daemon}->accept; # blocks return undef unless $conn; my $req = $conn->get_request; unless ($req) { $self->_debug( 'Problem reading from connection: ' . $conn->reason ); next CONNECTION; } if ($req->method ne 'POST') { my $r = new HTTP::Response (405,'POST method only' ); $conn->send_response($r); $conn->close; next CONNECTION; } elsif (my $content = $req->content) { my $r = new HTTP::Response(200, 'OK'); $conn->send_response($r); $conn->close; return $content; } } }