discussions-and-proposals
discussions-and-proposals copied to clipboard
Default User-Agent header for all networking requests should include the App Name and Version
Introduction
Currently the user agents used by iOS and Android for network requests differ. See https://github.com/facebook/react-native/issues/30163
For me the User-Agent is an integral parts of proper Client/Server communication for various scenarios (tailoring responses alongside Accept headers, sun-setting of endpoints, tracking, logging)
The user agent should therefore include the app name and version and be part of every requests of the fetch
, XMLHttpRequest
and Image
APIs.
Details
iOS is already including the app name + version in all its fetch
/Image
requests.
Android does
However on both platforms user agents can only be set on a per-request level, not globally. I propose that the networking layer includes the user agent with the appname by default on all platforms (not only iOS). The "okhttp/version" stays in the Android user agent.
I a second step a new global Networking.userAgent
could allow to override the global user agent if apps need special tokens in there.
The current per-request header settings is not affected by this proposal. It stays in the hand of the app developer.
Discussion points
-
What problems could arise from changing the default user agent on Android to include the App name + version like on iOS (beside the okhttp client it already contains today)?
-
Should the global override sit on a new
Networking
namespace or on eachfetch
,XMLHttpRequest
andImage
individually?