gpt4 book ai didi

Magento - 从服务器收到重复的 header

转载 作者:行者123 更新时间:2023-12-04 23:28:08 25 4
gpt4 key购买 nike

问题是,当我过滤订单导出时,有时我会在 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 修复它。

最佳答案

在这种情况下,似乎 magento 没有正确发送 header 。

这不是这里的“文件名中的逗号”错误,但看起来 Magento 发送了两次相同的 header 。

您可以通过更改 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 .

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

关于Magento - 从服务器收到重复的 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9103415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com