You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently there are are two documented value return values for a run mode, a scalar and scalarref.
I think we should consider adding a third: If the return value is an arrayref, it would be expected to be a complete PSGI response that's passed through directly (without adding a response code or headers as we usually would.
Use Case
CGI::Application::Plugin::Stream could be replaced with a native PSGI solution. To stream a file, you could end a run mode like this:
Like the Stream plugin, this would handle detecting the MIME Type and setting a Content-Type and Last-Modified headers, and converting it to a file handle. The server-side of the PSGI spec takes things from there.
I think if we don't add this, we'll end up needlessly rewriting solutions for cases like this, when we could be taking advantage of a native PSGI solution.
The text was updated successfully, but these errors were encountered:
How can you process the PSGI arrayref in CGI environment?
It seems that CGI::Application needs to do what Plack::Handler::CGI does.
I believe you are talking about PSGI::Application, not CGI::Application ;)
@anazawa, I only intended the feature to work in CGI::Application. Implementing and documenting it in PSGI::Application would certainly be simpler, as there is only one code path. Still, I think it could of interest in CGI::Application: "When using run_as_psgi()", run modes have a third valid return value, which is to to return the PSGI arrayref directly, which includes in the HTTP response status code, HTTP headers and the full response. This is useful for example for streaming tools, that take care of generating all the headers as well as a callback for the body.
Currently there are are two documented value return values for a run mode, a scalar and scalarref.
I think we should consider adding a third: If the return value is an arrayref, it would be expected to be a complete PSGI response that's passed through directly (without adding a response code or headers as we usually would.
Use Case
CGI::Application::Plugin::Stream could be replaced with a native PSGI solution. To stream a file, you could end a run mode like this:
Like the Stream plugin, this would handle detecting the MIME Type and setting a Content-Type and Last-Modified headers, and converting it to a file handle. The server-side of the PSGI spec takes things from there.
I think if we don't add this, we'll end up needlessly rewriting solutions for cases like this, when we could be taking advantage of a native PSGI solution.
The text was updated successfully, but these errors were encountered: