HTTP POST 请求中的自定义内容类型?

时间:2021-07-26 14:57:54

标签: http http-headers

我有一个自定义数据格式,我在 HTTP 帖子正文中发送。我想知道我是否应该使用 text/plainapplication/octet-stream,或者我是否可以使用自定义 Content-Type?定制是不是味道不好?

格式如下:

test0,id=28084 type=high,18765003 138456387

1 个答案:

答案 0 :(得分:1)

使用自定义 mime 类型是个好主意。

如果您的产品名称是“sally”,您可以例如使用:

application/prs.sally.testresults
application/vnd.sally.testresults
text/prs.sally.testresults
text/vnd.sally.testresults
application/x.sally.testresults
application/x.sally.testresults
text/x.sally.testresults
text/x.sally.testresults

prs 代表“个人”,vnd 代表“供应商”,x 代表未注册。

你被正式要求注册你的 prsvnd mimetypes,但坦率地说很少有人这样做,只要你制作一个努力使其具有合理的独特性。

applicationtext 之间的区别可能非常微妙,因为 JSON 和 Javascript 之类的东西也使用 application

通常使用 application 意味着像代理这样的中间体永远不会尝试自动更改字符编码等内容,而 text 可能会。

如果更像是计算机解释的格式,我可能更喜欢 application,如果它更像是人类可读的文本,那么 text 可能是正确的做法。

相关问题