11
votes

I'm looking to see whether this is correct as an HTTP response header

  Content-Type: application/pdf; charset=ISO-8859-1

or we should be emitting this instead

  Content-Type: application/pdf

I believe the latter is correct, given this:

The "charset" parameter is used with some media types to define the character set (section 3.4) of the data. When no explicit charset
parameter is provided by the sender, media subtypes of the "text"
type are defined to have a default charset value of "ISO-8859-1" when received via HTTP. Data in character sets other than "ISO-8859-1" or
its subsets MUST be labeled with an appropriate charset value.
rfc2068 HTTP/1.1

And that rfc3778 The application/pdf Media Type doesn't mention charsets at all.

This SO discussion is where I started, but isn't specifically about application/pdf: Is it categorically wrong to send a charset parameter with a Content-Type header for non-text media types?

Can anyone confirm or deny or point me to a better RFC?

1
what is the correct charset for a application/pdf - none! PDF files are binaries and charset shall only be suplied for textual data.mkl

1 Answers

21
votes

There is no charset value applicable. PDF is a binary format which handles character encodings internally, in a way that's not relevant to MIME types at all.

You should be sending:

Content-Type: application/pdf