Magento - 从服务器收到的重复标头

时间:2012-02-01 21:10:16

标签: magento google-chrome magento-1.5 export-to-csv

问题是,当我过滤订单导出时,有时我会在Google Chrome中收到此错误:

Duplicate headers received from server
The response from the server contained duplicate headers. This problem is generally the result of a misconfigured website or proxy. Only the website or proxy administrator can fix this issue.
Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Multiple Content-Disposition headers received. This is disallowed to protect against HTTP response splitting attacks.

我在谈论Sales > Orders屏幕。

假设我用订单号过滤它,这样我只想将1个实际订单导出到.csv文件。

在FF,IE等中,这似乎有效。大多数情况下它也适用于Chrome(16 - 此发布时的最新版本)。

根据这篇文章:'Duplicate headers received from server' Error in Chrome 16 with EPPlus 2.9他能够推断出它与“,”作为分隔符有关。

我尝试转到lib/Varien/File/Csv.php并将分隔符更改为“;”但这似乎不起作用......

有人有任何建议吗?

注意: Chrome本身有一些修复(我认为),但如果可能,我想通过Magento修复它。

1 个答案:

答案 0 :(得分:8)

似乎magento在那种情况下没有正确发送标题。

它不是文件名中的"逗号"这里的错误,但它看起来像Magento两次发送相同的标题。

您可以通过更改app/code/core/Mage/Core/Controller/Varien/Action.php中的3行来解决此问题。查看_prepareDownloadResponse方法并更改以下内容:

$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Pragma', 'public', true)
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
->setHeader('Content-type', $contentType, true)
->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength)
->setHeader('Content-Disposition', 'attachment; filename="'.$fileName.'"')
->setHeader('Last-Modified', date('r'));

通过

$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Pragma', 'public', true)
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
->setHeader('Content-type', $contentType, true)
->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true)
->setHeader('Content-Disposition', 'attachment; filename="'.$fileName.'"', true)
->setHeader('Last-Modified', date('r'), true);

最好不要将此更改应用于核心类,而是创建此类的副本并将其放在此处:/app/code/local/Mage/core/Controller/Varien/Action.php

在Magento 1.7的下一个版本中看起来像这个错误will be fixed