rama_ua/ua/mod.rs
1use serde::{Deserialize, Serialize};
2
3mod info;
4pub use info::{
5 DeviceKind, HttpAgent, PlatformKind, TlsAgent, UserAgent, UserAgentInfo, UserAgentKind,
6};
7
8mod parse;
9use parse::parse_http_user_agent_header;
10pub(crate) use parse::{contains_ignore_ascii_case, starts_with_ignore_ascii_case};
11
12/// Information that can be used to overwrite the [`UserAgent`] of an http request.
13///
14/// Used by the `UserAgentClassifier` (see `rama-http`) to overwrite the specified
15/// information duing the classification of the [`UserAgent`].
16#[derive(Debug, Clone, Default, Serialize, Deserialize)]
17pub struct UserAgentOverwrites {
18 /// Overwrite the [`UserAgent`] of the http `Request` with a custom value.
19 ///
20 /// This value will be used instead of
21 /// the 'User-Agent' http (header) value.
22 ///
23 /// This is useful in case you cannot set the User-Agent header in your request.
24 pub ua: Option<String>,
25 /// Overwrite the [`HttpAgent`] of the http `Request` with a custom value.
26 pub http: Option<HttpAgent>,
27 /// Overwrite the [`TlsAgent`] of the http `Request` with a custom value.
28 pub tls: Option<TlsAgent>,
29}
30
31#[cfg(test)]
32mod parse_tests;