How to fix ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION error in Google Chrome/Microsoft Edge

Google Chrome, along with its open source sibling - Chromium has rise from just another project at Google to be the most popular browser in the entire world. The Chromium project, on which Google Chrome is mainly based, is a very good browser by design. It can be used as a framework to quickly create a fast, modern and feature-packed browser, as well as desktop applications such as Visual Studio Code, Atom, Slack, etc.

Other notable names in the market are Google Chrome itself, Microsoft Edge, Vivaldi, Brave, Opera. They all share the same core, therefore if you use one of them, there's a high chance you might have seen ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION error. The error message should look like the image below.

ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION

This article will explain why ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION happens and go through a few ways you can do to fix it.

What causes ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION error?

Normally, the Content-Disposition response header is used to determine whether the response body should be displayed inline in the browser or be downloaded and saved locally. Most of the ordinary HTML web pages should be parsed and presented to the user right away, while documents and files should trigger a "Save as" pop-up.

In a multipart/form-data body, the HTTP Content-Disposition general header is a header that must be used on each subpart of a multipart body to give information about the field it applies to. The subpart is delimited by the boundary defined in the Content-Type header. Used on the body itself, Content-Disposition has no effect.

There is more about this specific header, if you want to know the details, go to Mozilla Web Docs to find out.

A typical Content-Disposition header should look like this in RAW mode :

Content-Disposition: inline
Content-Disposition: attachment
Content-Disposition: attachment; filename="filename.jpg"
Content-Disposition: attachment; filename=filename.jpg

ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION error should be followed by "invalid response" message. The error indicates that the Content-Disposition header sent back from the server contains multiple values.

Fix ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION in Chrome/Microsoft Edge

Let's suppose you were interacting with a website/app and trying to upload a file when you encountered the error. In this case, you should try again with a different file to determine whether the error comes from your browser (client-side) or from the server (server-side).

If the application/website works well with a different file, then we can conclude that the error comes from your side.

Most of the time, ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION error pops up when you try to upload a file with a comma included in its name. So that comma would be mistakenly detected as an array separator, splitting the name in halves. The response header now should look like this

Content-Disposition: attachment; filename=bizzare,file.jpg

To fix ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION , simply remove the comma from the filename and try again. Alternatively, switch to IE or Firefox, they are not suffered from this error because they added measures to safely process headers.

Fix ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION in your code

If you have access to the server or you are the developer, you can add code to wrap the filenames in double quotes, thus avoiding HTTP header mismatches. Alternatively, you can safely escape any comma in the filename before sending it out.

Here's a few solutions written in various programming language.

Python/Django/Flask

Response['Content-Disposition'] = 'attachment; filename="{fname}"'.format(fname=fname);

PHP/Laravel

$file_name = str_replace(array('"', "'", ' ', ','), '_', $file_name);
# OR
header('Content-Disposition: attachment; filename="'.$file_name.'"');
Click to rate this post!
[Total: 33 Average: 5]

Leave a Comment