【问题标题】:Magento - Duplicate headers received from serverMagento - 从服务器收到重复的标头
【发布时间】:2012-02-24 13:57:04
【问题描述】:

问题是当我过滤订单导出时,有时我会在 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 google-chrome magento-1.5 export-to-csv


    【解决方案1】:

    在这种情况下,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

    【讨论】:

    • 在 Magento 1.4.2.0(可能在以下版本)中,此类的本地覆盖可能应该在路径 app/code/local/Mage/Controller/Varien/Action.php 中。尽管必要的更改在core/Mage/Adminhtml/Controller/Action.php 中,但我遇到了同样的问题。希望这对某人有所帮助。
    猜你喜欢
    • 2012-11-14
    • 2015-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多