RFC Send Response Workflow#3105
Conversation
There was a problem hiding this comment.
The changes in this file are backwards incompatible and cannot be made in ZF2.
|
I've also left comments on the RFC, @prolic |
- implemented changes proposed by weierophinney - reverted changes in Console\Response and PhpEnvironment\Response objects - added Zend\Mvc\View\SendResponseListener extending the new class - added ResponseListenerFactory - Response sender triggers events
|
This also fixes a so far unknown issue: If your controller returns a custom response object (e.g. return new StreamResponse), this response object was not set in Zend\Mvc\Application and also not updated in Zend\ServiceManager\ServiceManager. When you call $serviceManager->get('Response') after returning a custom response in controller, you will now get the correct response object. (see changes in Zend\Mvc\Application) |
There was a problem hiding this comment.
I wouldn't track this in the response. I'd instead do a hash map of splobjectid => flag -- you can then check the given $response object against that to see if it has been sent.
|
About headers_sent(): @weierophinney how do you think we should handle this? After calling "header($someHeaderString)" there are still no headers sent and "headers_sent()" returns false. Headers are sent, when content gets sent, too. When we change the implementation to use "headers_sent()", it would no longer mean, that "header($someHeaderString)" was called. |
|
RFC document at http://framework.zend.com/wiki/display/ZFDEV2/RFC+-+Send+response+workflow needs to be updated. However the open questions remain:
|
|
@prolic re:
Basically, |
There was a problem hiding this comment.
Why is this needed, exactly?
|
@prolic So, only one question really remains in your list: if we should allow sending alternate Response types. My answer is yes. There are a couple ways to manage this:
The first is easier and faster to implement, but less flexible. The second will take more time, and require more objects, but be completely flexible. |
|
@weierophinney thanks for your input. I will update this PR and the RFC document tomorrow. |
- added SendResponseEvent - ResponseSender listen for an event - first response sender that can send the response, stops propagation - send response listener just triggers event, sends no response - SendResponseEvent tracks which response headers and content were sent - send response listener attaches default listeners (phpenvironmentresponse and consoleresponse, stream response sender is in progress) - removed AbstractResponseSender
|
updated worflow, document still out of date, see last commit message |
added default name in SendResponseEvent removed unused factories
|
todo: add stream response sender, write tests |
|
@prolic Let me know when this is ready to review again. |
|
I will add the stream response sender in a separate PR, as there is probably more to discuss. All tests are running again. Ready for review. |
see: http://framework.zend.com/wiki/display/ZFDEV2/RFC+-+Send+response+workflow