gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 15:05:34 25 4
gpt4 key购买 nike

是字段:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com