ZoFreX
ZoFreX

Reputation: 8920

Is it categorically wrong to send a charset parameter with a Content-Type header for non-text media types?

I've tracked down a bug between two pieces of software, one of them is emitting the header

Content-Type: application/x-bittorrent; charset=utf-8

And the other is handling this incorrectly, but handles it correctly if the charset parameter is dropped. I need to know which software to write a patch for!

According to the W3C's website:

Documents transmitted with HTTP that are of type text, such as text/html, text/plain, etc., can send a charset parameter in the HTTP header to specify the character encoding of the document.

Which implies that documents not of type text should not send this header, I think. However, RFC 2068 states:

The "charset" parameter is used with some media types to define the character set (section 3.4) of the data

I cannot find anywhere in the spec that it is incorrect to add a charset parameter to media types other than text, so my question is: Is the software emitting this header incorrect, or the software consuming it?

Upvotes: 3

Views: 752

Answers (2)

ZoFreX
ZoFreX

Reputation: 8920

I think it is incorrect to add a charset parameter for anything other than a text/* media-type, as the spec only permits adding charset for that.

Upvotes: -1

Julian Reschke
Julian Reschke

Reputation: 42017

(1) The relevant spec if RFC 2616, not 2068.

(2) The HTTP spec is correct, it depends on the media type. For instance, you can send a charset parameter for application/xml.

(3) Dunno about application/x-bittorrent - does it have a spec?

Upvotes: 3

Related Questions