I have a Java
module that receives the User-Agent
string from an end user's browser needs to behave slightly differently depending on the type of browser, the version of the browser and maybe even the operating system.
E.g.: {"FireFox", "7.0", "Win7"}
, {"Safari", "3.2", "iOS9"}
I understood that the User-Agent
string can vary in its format for the exact same configuration due to different plug-in installations etc.
My questions:
User-Agent
well defined? If yes - where can I find it exactly? (From my understanding of the RFC there is not much standardization here).No
- is there a proper way to parse it to get the info I need? User-Agent
string?Important note - I'm talking about a web-app, so my data collection abilities are limited to javascript
.
Have a look at the Java library I wrote for this purpose: Yauaa
I made a very simple servlet where you can try it out to see if it gives the answers you are looking for: https://try.yauaa.basjes.nl/
It is Apache 2 licensed and published into Maven so using it in a Java application is really easy. It is currently used in production on one of the busiest websites of the Netherlands (where I work).
See this blog about this https://techlab.bol.com/making-sense-user-agent-string/