What is the HTTP “content-type” to use for a blob of bytes?

时光毁灭记忆、已成空白 提交于 2019-12-05 08:31:26

问题


What is the HTTP "content-type" to use when returning a blob of bytes in response to a client's GET request?

In this case, the information payload is an object serialized using Python's Pickle library.


回答1:


You should use application/octet-stream.




回答2:


You should use the proper mime type:

application/python-pickle

This is the de-facto standard (this mean: it is not application/pickle or application/pickle-python).

RFC2046 states:

4.5.3. Other Application Subtypes It is expected that many other subtypes of "application" will be defined in the future. MIME implementations must at a minimum treat any unrecognized subtypes as being equivalent to "application/octet- stream".

So, to a non-pickle-aware system, the stream will look like any other octet-stream (you are not doing anything which will break existing apps), but to a pickle-aware system this is vital information.



来源:https://stackoverflow.com/questions/13223855/what-is-the-http-content-type-to-use-for-a-blob-of-bytes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!