User-agent parser / accessor on Request
Tronic opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe.
The user-agent string is notoriously difficult to decipher. Suggesting to have request.user_agent
with properties for browser and OS (in contrast to request.header.user_agent
which is the raw header), alike to how we return the Accept header parsed. This would be useful for logging/statistics as well as to workaround certain browser incompatibilities that are otherwise not possible to test for strictly server-side.
Describe the solution you'd like
There are various ways to approach this, ranging from just returning the UA string but with the compatibility cruft removed (i.e. the way it should be if Internet wasn't broken), to providing separate accessors for browser, browser-version, platform, etc.
Additional context
https://pypi.org/project/httpagentparser/
https://github.com/pallets/werkzeug/blob/main/src/werkzeug/user_agent.py