Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP::Server::PSGI returns an undef writer callback when writing headers failed #272

Open
miyagawa opened this issue Mar 8, 2012 · 2 comments

Comments

@miyagawa
Copy link
Member

miyagawa commented Mar 8, 2012

HTTP::Server::PSGI passes an undef to the application when writing HTTP headers failed in the streaming mode.

214     $self->write_all($conn, join('', @lines), $self->{timeout})
215         or return;

I just can't tell if it 's a bug since this is unspecified in the PSGI specification but it's not the optimal since the caller application will eventually die out by calling undef as a sub reference.

@miyagawa
Copy link
Member Author

miyagawa commented Mar 8, 2012

One option is to update the code to return a null callback so the caller won't die out.

The other possibility is to update the spec to read like "the server MAY (or SHOULD) provide an undef writer callback when writing HTTP headers to the client failed earlier" or something like that - at least it will match the existing behaviors to the specification, and also a potential optimization in the caller's code, since they can know that the client already disconnected, and there's no need to continue the application process to write out the body which could be expensive, when nobody is listening.

@miyagawa
Copy link
Member Author

miyagawa commented Mar 8, 2012

Just for the note -

  • Starman ignores the syswrite ret value from headers, continuing with writer
  • Twiggy the same
  • Starlet shares the same code base with HTTP::Server::PSGI, could return undef writer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant