Is it categorically wrong to send a charset parame

2019-07-02 12:00发布

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?

2条回答
Explosion°爆炸
2楼-- · 2019-07-02 12:40

(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?

查看更多
▲ chillily
3楼-- · 2019-07-02 12:46

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.

查看更多
登录 后发表回答