Feersum icon indicating copy to clipboard operation
Feersum copied to clipboard

Issue Sending empty response

Open Tim-Tom opened this issue 8 years ago • 0 comments

Looks like ev never gets back the idle loop if you send a response with no content body. The response is sent successfully and requests continue to be handled, but the lack of idle state probably points to a deeper issue. Simple test script which will print request received and idle called once, then only request received.

use strict;
use warnings;

use EV;
use AnyEvent;

use Feersum::Runner;

my $req_count = 0;

sub app {
  my $req = shift;
  my $idle;
  $idle = AnyEvent->idle(cb => sub { local $| = 1; print "Idle Called!\n"; $idle = undef; });
  {
    local $| = 1;
    print "Request received\n";
  }
  if (++$req_count == 2) {
    $req->send_response(204, [], '');
  } else {
    $req->send_response(200, ['Content-Type' => 'text/plain; charset=utf-8'], 'A response');
  }
}

my $runner = Feersum::Runner->new(listen => ['localhost:4321'], pre_fork => 0, quiet => 0);

$runner->run(\&app);

Tim-Tom avatar Mar 01 '17 23:03 Tim-Tom