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

Add method to prevent sending of response after action completes #37

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public function onInsertAction()
*/
public function thumbnailAction()
{
$this->getResponse()->disableOutput();
$file = $this->getRequest()->getParam('file');
$file = Mage::helper('Mage_Cms_Helper_Wysiwyg_Images')->idDecode($file);
$thumb = $this->getStorage()->resizeOnTheFly($file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Mage_Adminhtml_Cms_WysiwygController extends Mage_Adminhtml_Controller_Act
*/
public function directiveAction()
{
$this->getResponse()->disableOutput();
$directive = $this->getRequest()->getParam('___directive');
$directive = Mage::helper('Mage_Core_Helper_Data')->urlDecode($directive);
$url = Mage::getModel('Mage_Core_Model_Email_Template_Filter')->filter($directive);
Expand Down
21 changes: 20 additions & 1 deletion app/code/core/Mage/Core/Controller/Response/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ class Mage_Core_Controller_Response_Http extends Zend_Controller_Response_Http
*/
protected static $_transportObject = null;

/**
* @var bool
*/
protected $_isOutputDisabled = false;

/**
* Disable response output; useful for situations where the response was already rendered such as
* with an image library that uses direct output.
*/
public function disableOutput()
{
$this->_isOutputDisabled = true;
}

/**
* Fixes CGI only one Status header allowed bug
*
Expand Down Expand Up @@ -77,10 +91,15 @@ public function sendHeaders()
return parent::sendHeaders();
}

/**
* Dispatch an event before the response is rendered and only render response if it is not disabled.
*/
public function sendResponse()
{
Mage::dispatchEvent('http_response_send_before', array('response'=>$this));
return parent::sendResponse();
if ( ! $this->_isOutputDisabled) {
return parent::sendResponse();
}
}

/**
Expand Down