HTTP Headers
User Agent
The HTTP User-Agent request header is a string that identifies the application, operating system, vendor, and version of the requesting user agent. This information helps servers and network peers understand the client making the request.
The User-Agent header is classified as a request header and is not a forbidden request header.
Syntax
Understanding the syntax for HTTP headers is essential for managing web communications. A typical format for specifying details about a client application, such as a web browser, is structured as follows:;
Common format for web browsers:
User-Agent: Mozilla/5.0 (<system-information>) <platform> (<platform-details>) <extensions>
Directives
Directives
- <product>
- A product identifier — its name or development codename.
- <product-version>
- Version number of the product.
- <comment>
- Zero or more comments containing more details. For example, sub-product information.
Example
For more details on user agent strings based on Firefox and Gecko engines, refer to the Firefox user agent string reference. The Firefox UA string is composed of four main parts.
Mozilla/5.0 (platform; rv:gecko-version) Gecko/gecko-trail Firefox/firefox-version
It includes these components:
- The token
"Mozilla/5.0"
signifies that the browser is compatible with Mozilla. This is a standard sent by nearly all browsers today. - The
platform
describes the operating system or device, such as Windows, Mac, Linux, or Android. For mobile devices like Firefox OS phones, it might be “Mobile”—indicating that the web platform is the environment. The platform can include multiple semicolon-separated tokens. - The
"rv:gecko-version"
indicates the Gecko engine’s release version, like “17.0”, and in recent browsers, it equals the Firefox version. - The
"Gecko/gecko-trail"
part shows Gecko as the underlying engine, with “20100101” being the fixed string in desktop browsers. - The
"Firefox/firefox-version"
specifies that the browser is Firefox and includes its version number.
Examples of Firefox UA strings include:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0
Chrome web browsers utilize a similar UA string structure but incorporate additional strings like “KHTML, like Gecko” and “Safari” for compatibility.
Example of a Chrome UA string:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
The Opera browser, which is based on the Blink engine, has a UA string similar to Chrome but adds “OPR/<version>”.
Example of Opera UA string:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36 OPR/38.0.2220.41
Older Presto-based Opera versions used:
Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.00
Opera/9.60 (Windows NT 6.0; U; en) Presto/2.1.1
Microsoft Edge, also based on the Blink engine, adds “Edg/<version>” to its UA string.
Example:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.59
Safari’s UA string, often for mobile Safari, contains “Mobile”.
Example:
Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1
Crawler and bot user agents include strings such as:
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
Mozilla/5.0 (compatible; YandexAccessibilityBot/3.0; +http://yandex.com/bots)
Library and network tool UA strings are also used, for example:
curl/7.64.1
PostmanRuntime/7.26.5
How to Modify Header using Requestly
Requestly is a powerful Chrome extension that allows you to modify HTTP headers, including the User-Agent header.
This is especially useful for testing how your application responds to requests from different browsers or devices during development or troubleshooting. Steps to Modify the User-Agent Header:
- Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
- Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
- Add a new header modification:
- Under “Action”, select “Add” or “Override”.
- In the “Header Name” field, enter User-Agent.
- In the “Header Value” field, enter the User-Agent string you want to simulate (e.g., Mozilla/5.0 (Windows NT 10.0; Win64; x64)).
- Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
- Save the rule.
Once set up, Requestly will inject the User-Agent header with your specified value into all matching requests, allowing you to simulate traffic from different browsers or devices for testing or debugging purposes. Modifying the User-Agent header helps you see how your website or API behaves for different devices or browsers. It lets you check if your content adapts correctly, or if there are any issues that only affect certain clients.
Table of Contents
- No headings found.