gpt4 book ai didi

http - HTTP 请求中缺少 User-Agent 是否有效?

转载 作者:可可西里 更新时间:2023-11-01 15:07:26 29 4
gpt4 key购买 nike

我们注意到,有时我们会收到没有有效用户代理字符串的 HTTP 请求。接受这种类型的 HTTP 请求是否有任何有效的现实案例?

为什么我们不自动阻止收到此类请求的所有 IP?

更新我用短语“真实世界”的意图是表明我不是在询问 HTTP 协议(protocol)允许什么。允许提交不带某些 header 的 HTTP 请求。我想问的是,允许这种类型的 HTTP 请求进入您的服务器的“真实世界”情况是什么。

最佳答案

RFC 7231 中所述(但在 RFC2616 中可以找到几乎相同的段落):

5.5.3 User-Agent

The "User-Agent" header field contains information about the user agent originating the request, which is often used by servers to help identify the scope of reported interoperability problems, to work around or tailor responses to avoid particular user agent limitations, and for analytics regarding browser or operating system use. A user agent SHOULD send a User-Agent field in each request unless specifically configured not to do so.

这里的关键词是应该。是的,有一个 RFC 定义了该词的含义,RFC 2119 :

  1. SHOULD This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.

因此,尽管不发送 User-Agent 的代理未遵循可被视为最佳实践的内容,但它们并未违反任何规则 (rfc)。因此,在我看来,没有真正有效的技术理由来阻止它们。

关于http - HTTP 请求中缺少 User-Agent 是否有效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24274789/

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