http - HTTP post 请求中的 Content-Type 是强制性的吗?

标签 http post

是字段:

Content-Type

当我执行 HTTP 请求时是强制性的?

最佳答案

不,这不是强制性的。根据 HTTP 1.1 specification :

Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its content and/or the name extension(s) of the URI used to identify the resource. If the media type remains unknown, the recipient SHOULD treat it as type "application/octet-stream".

也就是说,如果您省略 Content-Type header ,服务器显然很难准确解释您发送的数据,因此不建议这样做。

关于http - HTTP post 请求中的 Content-Type 是强制性的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15860742/

相关文章:

php - 我应该使用什么 HTTP 重定向状态来链接异地?

java - Http Post 和网络延迟

c# - 从 silverlight 导航和发布数据

android - 如何在 android apk 文件中保护 web 服务 url

http - CalDAV 客户端的 Report 方法不请求新的事件数据

php - PHPs fopen 会遵循 301 重定向吗?

java - UrlEncodedFormEntity 不编码下划线

java - tomcat7 上的 servlet eclipse HTTP 状态 405 - 此 URL 不支持 HTTP 方法 POST

http - 求助,不知道我的 HTTP multipart POST 有什么问题

api - 为 POST 请求返回 200 Ok HTTP 状态是否正确?