Documentation
¶
Index ¶
Constants ¶
View Source
const ( HeaderSecChUa = "Sec-Ch-Ua" HeaderSecChUaArch = "Sec-Ch-Ua-Arch" HeaderSecChUaBitness = "Sec-Ch-Ua-Bitness" HeaderSecChUaFullVersion = "Sec-Ch-Ua-Full-Version" HeaderSecChUaFullVersionList = "Sec-Ch-Ua-Full-Version-List" HeaderSecChUaMobile = "Sec-Ch-Ua-Mobile" HeaderSecChUaModel = "Sec-Ch-Ua-Model" HeaderSecChUaPlatform = "Sec-Ch-Ua-Platform" HeaderSecChUaPlatformVersion = "Sec-Ch-Ua-Platform-Version" )
User-Agent-Client-Hints Headers
Variables ¶
View Source
var PrimaryBrands = []string{
"Google Chrome",
"Chrome",
"Microsoft Edge",
"Edge",
"Brave Browser",
"Brave",
"Yandex Browser",
"Yandex",
"CocCoc",
"Opera",
"Vivaldi",
"SRWare Iron",
"Epic Privacy Browser",
"Comodo Dragon",
"Torch Browser",
"Samsung",
}
Brand array A array of brands that Sec-Ch-Ua prefers to compare.
View Source
var SecondaryBrands = []string{
"Chromium",
}
This array will be used to try to get the brand name if it is not in the PrimaryBrands array.
Functions ¶
func IsSupportClientHints ¶
Determines if ClientHint is supported.
It is determined by the presence or absence of the `Sec-Ch-Ua` header.
Types ¶
type Brand ¶
type Brand struct { Brand string `json:"brand,omitempty"` BrandVersion string `json:"brand_version,omitempty"` Brands map[string]string `json:"brands,omitempty"` }
Sec-CH-UA field
func ParseSecChUa ¶
Parse the `Sec-Ch-Ua` header Create an array of brand names and their versions, plus determine which one of the brands you are using.
type ClientHints ¶
type ClientHints struct { Brand // Sec-Ch-Ua-Platform filed Platform Platform `json:"platform"` // Sec-CH-UA-Platform-Version filed PlatformVersion string `json:"platform_version,omitempty"` // Sec-Ch-Ua-Mobile filed IsMobile bool `json:"is_mobile"` // Sec-CH-UA-Arch filed Architecture string `json:"architecture,omitempty"` // Sec-CH-UA-Bitness filed Bitness int `json:"bitness"` // Sec-CH-UA-Model filed Model string `json:"model,omitempty"` // Sec-Ch-Ua-Full-Version filed FullVersion string `json:"full_version,omitempty"` }
func Parse ¶
func Parse(headers *http.Header) (*ClientHints, error)
Parse User-Agent Client Hints.
Parse the header below.
- Sec-Ch-Ua
- Sec-Ch-Ua-Arch
- Sec-Ch-Ua-Bitness
- Sec-Ch-Ua-Full-Version
- Sec-Ch-Ua-Full-Version-List
- Sec-Ch-Ua-Mobile
- Sec-Ch-Ua-Model
- Sec-Ch-Ua-Platform
- Sec-Ch-Ua-Platform-Version
If the header does not exist, its value will be the empty string, the number 0, or false.
type Platform ¶
type Platform string
const ( Android Platform = "Android" ChromeOS Platform = "Chrome OS" ChromiumOS Platform = "Chromium OS" IOS Platform = "iOS" Linux Platform = "Linux" MacOS Platform = "macOS" Windows Platform = "Windows" Unknown Platform = "Unknown" )
Platforms You get `Sec-Ch-Ua-Platform` field
func ParsePlatform ¶
Prase the `Sec-CH-UA-Platform` header
Click to show internal directories.
Click to hide internal directories.