Feersum
Feersum copied to clipboard
psgi.input being undef causes exceptions elsewhere
In the docs it says
Feersum currently passes undef for psgi.input when there is no body to avoid unnecessary work.
Which makes sense, except it causes HTTP::Entity::Parser to throw an exception:
Can't call method "seek" on an undefined value at /usr/local/share/perl/5.22.1/HTTP/Entity/Parser.pm line 71.
I opened an issue there too: https://github.com/kazeburo/HTTP-Entity-Parser/issues/6
I'm not exactly clear on the PSGI spec's take on this, but it seems to say it must be an IO::Handle-like object?
Thanks,
Doug
Just to be clear, I am seeing this when I issue a POST request with an empty body (admittedly somewhat of an edge case.
Here is a test-case:
use Feersum;
use AnyEvent;
use Plack::Request;
my $socket = IO::Socket::INET->new(Listen => 5, Proto => 'tcp', LocalPort => 9999, ReuseAddr => 1, Blocking => 0) || die "unable to listen: $!";
my $f = Feersum->endjinn;
$f->use_socket($socket);
$f->psgi_request_handler(sub {
my $env = shift;
my $req = Plack::Request->new($env);
$req->parameters;
return [200, [], []];
});
AE::cv->recv;
When it's running, hit it with curl:
curl http://localhost:9999 -d ''
And you'll see the error:
(in cleanup) DIED: Can't call method "seek" on an undefined value at /usr/local/share/perl/5.22.1/HTTP/Entity/Parser.pm line 71.
Thanks for the report. Try commenting out lines 1579 and 1582 in Feersum.xs
and see if it works for you?
Thanks! Yes that fixes it (you have to comment out 1583 and 1585 as well so it compiles).
I guess this adds some overhead to GET requests since even then it will create an empty stream. I'm not sure if that's important?
This change caused the tests to fail in the latest version.
However, with HTTP::Entity::Parser
0.20, this problem no longer happens and the test script above works without issue.
Would it be appropriate to revert these changes, so that Feersum can be installed without failing the graceful shutdown unit test? And perhaps mandate HTTP::Entity::Parser 0.20 as a dependency?
I can send a PR, if the solution works for you :)
That works, please send the PR and looking forward to a new release with your contribution.
Thanks @audreyt :)
The remaining test failures seem to only affect the BSDs... If I can diagnose the issue, I'll send another PR.