hapi-server / client-python

Python client for HAPI
BSD 3-Clause "New" or "Revised" License
12 stars 10 forks source link

allow client to set the USER-AGENT to support testing #63

Open jbfaden opened 1 year ago

jbfaden commented 1 year ago

It would be nice to set the User-Agent so that HAPI servers can filter requests made for testing from those where it's being used for science.

To set it in Python, it is something like:

USER_AGENT = 'hapibot-a/1.0; https://github.com/hapi-server/data-specification/wiki/hapi-bots.md#hapibot-a'
headers= { "User-Agent" : USER_AGENT }
x = requests.get(cS,headers=headers)

I'd suggest this would be an option in the **opts structure, like so:

agent= 'hapibot-z/1.0; https://github.com/hapi-server/data-specification/wiki/hapi-bots.md#hapibot-z'
opts = {'logging': False, 'format': 'csv', 'usecache': True, 'useragent':agent}
hapidata = hapiclient.hapi(server, dataset, parameters, start, stop, **opts)