Is there an RFC, official standard, or template for creating a User Agent string? The iphone’s user-agent string seems strange…
Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16
Note: In June 2022 the IETF (Internet Engineering Task Force) published
RFC9110, which obsoletedRFC7231, therefore I’m updating this answer with the new RFC information.The
User-Agentheader is part of theRFC9110, which describes the HTTP Semantics, where is states:EBNF Specification
Where
productis defined as:And
commentis defined as:Other rules for reference:
Note that this means that
productcannot contain spaces, butcommentscan.Examples:
Here are some valid examples of
productstrings (with and withoutproduct-versionstrings):Here are some valid examples of
commentstrings; note how all strings are enclosed in matched parentheses():As a
User-Agentheader’s value is comprised of arbitraryproductandcommentstrings, these are all validUser-Agentheaders: