pub struct Profile { /* private fields */ }user-agents only.Expand description
A browser version and platform with navigation headers for a page opened directly.
The latest capture supplies header values; other major versions substitute the version into the user agent and Chromium client hints. This does not emulate TLS, HTTP/2, or the browser’s networking stack.
use uagent::{Browser, Platform, Profile};
let profile = Profile::new(Browser::Chrome, Platform::Windows)?;
assert_eq!(profile.version(), Browser::Chrome.latest());Implementations§
Source§impl Profile
impl Profile
Sourcepub fn new(browser: Browser, platform: Platform) -> Result<Profile, Error>
pub fn new(browser: Browser, platform: Platform) -> Result<Profile, Error>
Creates a profile of browser on platform at its latest bundled version.
§Errors
Returns an error if the browser/platform combination has no template.
Sourcepub fn with_version(self, version: u32) -> Result<Profile, Error>
pub fn with_version(self, version: u32) -> Result<Profile, Error>
Overrides the browser’s major version.
Other major versions reuse the latest captured navigation headers; historical header changes are not modeled.
§Errors
Returns Error::InvalidVersion if version is zero.
Sourcepub const fn with_latest_version(self) -> Profile
pub const fn with_latest_version(self) -> Profile
Restores the browser’s latest bundled major version after an override.
Sourcepub fn with_language(self, language: &str) -> Result<Profile, Error>
pub fn with_language(self, language: &str) -> Result<Profile, Error>
Overrides the captured Accept-Language value.
Accepts a BCP 47 language tag or a comma-separated list of language tags
and optional quality values, such as de-DE,de;q=0.9. * is also allowed.
§Errors
Returns Error::InvalidLanguage for invalid tags, quality values,
or characters that cannot appear in the header.
Sourcepub fn user_agent(&self) -> String
pub fn user_agent(&self) -> String
Returns the captured user agent with the requested version and platform.
Chromium reduces its version to the major; Safari retains the captured minor/patch suffix. Platform variants without captures use the draft’s fixed platform descriptions.
Sourcepub fn headers(&self) -> Vec<Header>
pub fn headers(&self) -> Vec<Header>
Returns header names and values in capture order, excluding transport
headers (Host, connection management, and Accept-Encoding).
Accept-Encoding belongs to the HTTP client, which knows its decoders.
Header order is a convenience for clients that support it; an HTTP header
map does not preserve it.