gpt4 book ai didi

c# 我应该对 useragent 进行空检查吗?

转载 作者:行者123 更新时间:2023-12-02 09:15:31 30 4
gpt4 key购买 nike

我将用户代理提取为:

string userAgent = HttpContext.Current.Request.UserAgent;

UserAgent 是否有可能为空?是否仅适用于机器人或任何合法用户/设备/客户端/浏览器?

最佳答案

User-Agent header 在 RFC 2616 中是可选的。它 SHOULD可供客户使用,但不是必需使用。另请参阅RFC7231 :

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.

认为 RFC7231 已经过时了 2616,但为了完整性我已经引用了两者。

所以,是的,您应该检查是否有 null 或空的用户代理。

关于c# 我应该对 useragent 进行空检查吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44782923/

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