Open MatzFan opened 3 months ago
There is an old discussion about this (https://qgis-developer.osgeo.narkive.com/xdzP8vT8/do-we-have-a-user-agent-string-for-qgis; https://issues.qgis.org/issues/8869) that I found while researching this specific issue a while back, and the consensus as far as I understand is that this behavior is intended primarily because a lot of public facing API requires an application to properly identify itself for them to log, filter, and throttle as they see fit.
With respect to interoperability and as a gesture to a lot of free data provider I think the current hard-coded User-Agent is proper and shouldn't be changed.
It's nothing deal-breaking and can easily be solved by a local proxy written in your favorite scripting language, however this MAY break the TOS of whatever data endpoint you're accessing. There is already an implementation written in Python in GitHub for unrelated issue (but can also be used to override the User-Agent) but I won't link it here.
@WhitespaceQ understood. I can see the logic, though I'd have thought a warning of some kind re potential TOS issues may be a suitable solution in QGIS - especially given how trivial it is to override - as you imply. I guess it comes down to a philosophical issue around whether one wants to try and limit functionality that could potentially be abused. If it is decided not to pursue this for that reason I'll understand and use a proxy or the Python hack you mention for my own needs. I personally think adding the functionality as described with an appropriate warning strikes the right balance. TOS abusers will not be discouraged anyhow, but legitimate uses can be catered for.
In any case I think the current behavior is potentially misleading. Changing the field descriptor to "User-Agent prefix" and maybe adding a tooltip or similar explaining that the custom User-Agent string prepends the default HTTP header might be useful, if the existing functionality remains the same.
In any case I think the current behavior is potentially misleading. Changing the field descriptor to "User-Agent prefix" and maybe adding a tooltip or similar explaining that the custom User-Agent string prepends the default HTTP header might be useful, if the existing functionality remains the same.
I agree and I think the behaviour should be made explicit in the documentation.
Feature description
Currently a default HTTP User-Agent header is set by default. It is of the form "QGIS/[version-as-integer]/[host-platform]".
There also exists the ability to set a custom User-Agent HTTP header string under Settings->Options->Network->User-Agent. However, presently this string does not override the default string but merely prepends the custom string to it.
It would be desirable to have the ability to override the default string by adding a tick box saying "Override default User-Agent" or similar to the UI. This would not be ticked by default so as to retain the current behavior for backwards compatibility. If ticked, the above default string would be overwritten by the user's default User-Agent. If unticked the current behavior would be retained.
Additional context
I personally find the current behavior unexpected. Browsers and many other software applications which issue HTTP requests provide the ability to set a custom HTTP User-Agent header. QGIS presently does not, just the ability to prepend the default with an additional string.