3.59Configuring User-Agent
Created on Aug 17, 2026~4 min read
The User-Agent request header is a characteristic string that allows servers and peer networks to identify the application, operating system, vendor, or version information of the user agent that issued the request. The framework provides the SetUserAgent method to set the User-Agent request header.
HttpRequestBuilder.Get("https://furion.net/logo.png") .SetUserAgent(UserAgents.Chrome.PC) // Conveniently set using the UserAgents static class .SetUserAgent(UserAgents.Chrome.Mobile) // Set to a mobile User-Agent .SetUserAgent(UserAgents.GetRandom()) // Randomly get a browser-type User-Agent .SetUserAgent(UserAgents.GetByBrowser("Safari")) // Get the User-Agent of a specified browser type .SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36"); // Or set the User-Agent string directlyUserAgents is a static class provided by the framework for conveniently setting the User-Agent identifiers of mainstream browsers, and it contains the following members:
-
Static methods:
GetRandom(isMobile): randomly gets a browser'sUser-Agent.GetByBrowser(browser, isMobile): gets theUser-Agentof a specified browser type.
-
Static members:
Chrome: Google Chrome browserPC: desktopUser-AgentidentifierMobile: mobileUser-Agentidentifier
Firefox: Mozilla Firefox browserPC: desktopUser-AgentidentifierMobile: mobileUser-Agentidentifier
Safari: Apple Safari browserPC: desktopUser-AgentidentifierMobile: mobileUser-Agentidentifier
Edge: Microsoft Edge browserPC: desktopUser-AgentidentifierMobile: mobileUser-Agentidentifier
Opera: Opera browserPC: desktopUser-AgentidentifierMobile: mobileUser-Agentidentifier
Generic: generic browserPC: desktopUser-AgentidentifierMobile: mobileUser-Agentidentifier