Magento - Duplicate headers received from the server

The problem is that sometimes I get this error in Google Chrome when filtering export orders:

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. 

I am talking about the screen Sales > Orders .

Say I'm filtering it with an order number , so I want to export only 1 actual order to a .csv file.

In FF, IE, etc. this seems to work. And most of the time it also works in Chrome (16 is the latest version at the time of publication).

According to this message: 'Duplicate headers received from the server "Error in Chrome 16 with EPPlus 2.9 , he was able to conclude that this is somehow connected", "as a meter.

I tried going to lib/Varien/File/Csv.php and changing the metric to ";" but that didn't seem to work ...

Anyone have any suggestions?

Note. There are some fixes for Chrome itself (I think), but I want to fix it through Magento, if possible.

+4
source share
1 answer

It seems that magento did not send the headers correctly in this case.

This is not a “comma in file name” error, but Magento seems to send the same header twice.

You can fix this problem by changing 3 lines in app/code/core/Mage/Core/Controller/Varien/Action.php . Take a look at the _prepareDownloadResponse method and change the following:

 $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')); 

by

 $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); 

It’s best not to apply this change to the main classes, but create a copy of this class and place it here: /app/code/local/Mage/core/Controller/Varien/Action.php .

It seems that this error will be fixed in the next version of Magento 1.7.

+8
source

Source: https://habr.com/ru/post/1394269/


All Articles