Duplicate Headers Received in Chrome

Duplicate Headers Received in Chrome

I recent started receiving errors when downloading files stored in a database and sent to the browser on a Classic ASP page (although the problem may occur in other languages as it appears to be a Chrome issue).

My original ‘downloader’ script below pulls the binary file data and related key information from a database and sends it to the browser:

SET fetchFileDataRS = readOnlyConn.Execute ("SELECT contentType, fileBinary, downloadFileName, sizeInKb FROM CUSTOMER_files WHERE downloadID = " & downloadID,,adCmdText)
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear
Response.AddHeader "Content-Disposition","attachment; filename=" & fetchFileDataRS("downloadFileName")
Response.BinaryWrite(fetchFileDataRS("fileBinary"))
Response.Flush
Response.End
SET fetchFileDataRS = NOTHING

To solve the problem, I simply added a REPLACE to the script to strip out commas from the filename sent to the browser:

SET fetchFileDataRS = readOnlyConn.Execute ("SELECT contentType, fileBinary, downloadFileName, sizeInKb FROM CUSTOMER_files WHERE downloadID = " & downloadID,,adCmdText)
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear
Response.AddHeader "Content-Disposition","attachment; filename=" & REPLACE(fetchFileDataRS("downloadFileName"), ",", "-")
Response.BinaryWrite(fetchFileDataRS("fileBinary"))
Response.Flush
Response.End
SET fetchFileDataRS = NOTHING
Bob McKay

About Bob McKay

Bob is a Founder of Seguro Ltd, a full time father and husband, part-time tinkerer-with-wires, coder, Muay Thai practitioner, builder and cook. Big fan of equality, tolerance and co-existence.

Disclosure Policy

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.