Expand description
User Agent (UA) parser and types.
This module provides a parser (UserAgent::new
) for User Agents
as well as a classifier (UserAgentClassifierLayer
in rama_http
) that can be used to
classify incoming requests based on their User Agent (header).
Learn more about User Agents (UA) and why Rama supports it at https://ramaproxy.org/book/intro/user_agent.html.
§Rama
Crate used by the end-user rama
crate and rama
crate authors alike.
Learn more about rama
:
- Github: https://github.com/plabayo/rama
- Book: https://ramaproxy.org/book/
§Remarks
We classify only the majority User Agents, and we do not classify all User Agents:
- All Chromium User Agents are classified as
UserAgentKind::Chromium
(including Google Chrome); - All Firefox User Agents are classified as
UserAgentKind::Firefox
; - All Safari User Agents are classified as
UserAgentKind::Safari
;
The only Platform
s recognised are Windows
,
MacOS
, Linux
,
Android
, and iOS
.
User Agent versions are parsed only their most significant version number (e.g. 124
for Chrome/124.0.0
and 1704
for Safari Version/17.4
). We do not parse the version for platforms as
these are no longer advertised in contemporary User Agents.
For UA Classification one can overwrite the HttpAgent
and TlsAgent
advertised by the UserAgent
,
using the UserAgent::with_http_agent
and UserAgent::with_tls_agent
methods.
UA Emulators are advised to interpret the UserAgent
in the following order:
- first try to find an emulation match using
UserAgent::header_str
; - otherwise try to find an emulation match using
UserAgent::info
: where theUserAgentKind
andPlatformKind
should be matched, and the version should be as close as possible to the version of theUserAgent
. - otherwise match the
DeviceKind
usingUserAgent::device
. - final fallback is to find emulation data for
DeviceKind::Desktop
.
Please open an issue in case you need support for more User Agents, and have a good case to make for it. For example we might also support the default user agents used by mobile application SDKs. This makes however only sense if we can provide Http and Tls emulation for it.
Structs§
- User Agent (UA) information.
- Information about the
UserAgent
- Information that can be used to overwrite the
UserAgent
of an http request.