是字段:
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/