What's the difference of ContentType and MimeType

后端 未结 4 2038
我在风中等你
我在风中等你 2020-12-13 02:00

As far as I know, they are absolute equal. However, browsing some django docs, I\'ve found this piece of code:

HttpResponse.__init__(content=\'\', mimetype=Non

4条回答
  •  佛祖请我去吃肉
    2020-12-13 02:36

    I've always viewed contentType to be a superset of mimeType. The only difference being the optional character set encoding. If the contentType does not include an optional character set encoding then it is identical to a mimeType. Otherwise, the mimeType is the data prior to the character set encoding sequence.

    E.G. text/html; charset=UTF-8

    text/html is the mimeType
    ; is the additional parameters indicator
    charset=UTF-8 is the character set encoding parameter

    E.G. application/msword

    application/msword is the mimeType
    It cannot have a character set encoding as it describes a well formed octet-stream not comprising characters directly.

提交回复
热议问题