Skip to content

Commit

Permalink
Add check for object since getHeader can return bool
Browse files Browse the repository at this point in the history
  • Loading branch information
Ho Minh Hiep committed Feb 2, 2016
1 parent b3f5588 commit 68d9a91
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ public function aroundDispatch(
*/
protected function addDebugHeaders(ResponseHttp $result)
{
$cacheControl = $result->getHeader('Cache-Control')->getFieldValue();
$this->addDebugHeader($result, 'X-Magento-Cache-Control', $cacheControl);
$this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'MISS', true);
$cacheControlHeader = $result->getHeader('Cache-Control');
if ($cacheControlHeader instanceof \Zend\Http\Header\HeaderInterface) {
$cacheControl = $cacheControlHeader->getFieldValue();
$this->addDebugHeader($result, 'X-Magento-Cache-Control', $cacheControl);
$this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'MISS', true);
}
return $result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ public function aroundRenderResult(
}

if ($this->state->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
$cacheControl = $response->getHeader('Cache-Control')->getFieldValue();
$response->setHeader('X-Magento-Cache-Control', $cacheControl);
$response->setHeader('X-Magento-Cache-Debug', 'MISS', true);
$cacheControlHeader = $result->getHeader('Cache-Control');
if ($cacheControlHeader instanceof \Zend\Http\Header\HeaderInterface) {
$cacheControl = $cacheControlHeader->getFieldValue();
$response->setHeader('X-Magento-Cache-Control', $cacheControl);
$response->setHeader('X-Magento-Cache-Debug', 'MISS', true);
}
}

$tagsHeader = $response->getHeader('X-Magento-Tags');
Expand Down

0 comments on commit 68d9a91

Please sign in to comment.