use of HTTP Content-Disposition

218 Views Asked by At

I have this code:

resp.addHeader("Content-Disposition", "inline; filename=" + fileName);

When the file name is a_b_c.doc or abc.doc the name of the downloaded file is displayed correctly.

However, when the file name is a b c .doc the name of the downloaded file is only a.

How can we work around this?

2

There are 2 best solutions below

0
On

Quote the filename: "filename.doc".

4
On

You always MUST quote the filename anyway. See §19.5.1 "Content-Disposition" in RFC 2616 Section 19 and $2.2 "Basic Rules" RFC 2616 Section 2 which defines "quoted-string".