Reputation: 2592
This only happens in Chrome, works great in Safari. Chrome is complaining that duplicate content-disposition headers are being received. When I upload a file to S3 I set the content disposition so that I can name the file upon download and also ensure it gets downloaded as an attachment (not inline).
Here's what I'm getting specifically:
Upvotes: 3
Views: 2876
Reputation: 2295
Duplicated header error on Chrome is a bug with the HTML header: "Content-disposition: attachment" when the filename comes with comma(s).
The solution here, we just add double quotes (") between filename as example:
Response.AddHeader("Content-Disposition", "attachment;filename=\"file,withcomma.pdf\"")
And this solution works for all browsers (as I tested on IE11, Chrome, Firefox)
Upvotes: 0
Reputation: 1
Original code:
header("Content-Disposition: attachment; filename=$displayname");
changed:
header('Content-Disposition: attachment; filename="'.$displayname.'"');
Upvotes: -1
Reputation: 2738
When I experienced this error it was because I had something like this:
Response.AddHeader("Content-Disposition", "attachment;filename=file,withcomma.pdf")
Chrome is interpreting this as two Content-Disposition headers: "attachment:filename=file" and ",withcomma.pdf".
Wrapping the filename in quotes resolved the issue for me:
Response.AddHeader("Content-Disposition", "attachment;filename=\"file,withcomma.pdf\"")
Upvotes: 2
Reputation: 1098
I've seen your question and I've just solved mine, though my code is asp.net. I started getting this error today, Chrome must have added some stricter handling of headers. Anyway, my bug turned out to be the part where I set the content-disposition header.
Instead of
Response.AppendHeader("Content-Disposition", "attachment,filename=abcdxyz.pdf")
I changed it to
Response.AppendHeader("Content-Disposition", "attachment;filename=abcdxyz.pdf")
The comma seemed to cause some kind of problem, switching to a semi-colon seems to fix it. It's now working fine for me, but I should mention that I am not familiar with Amazon S3 (at all) so maybe I'm waaaay off, but since it has just worked for me, maybe it'll work for you.
Upvotes: 0