diff options
author | Luca Fabbri <lucafbb@gmail.com> | 2023-02-28 16:58:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-28 15:58:14 +0000 |
commit | c41b0dbc50572d96ecc4cb2298a887f6fcbd5daa (patch) | |
tree | b21df2ebcd396e6cc1f68e51e416f47e96f8cd86 /cdsapi/api.py | |
parent | 5862e1fb09c99a47f5adff0d6ac7625331edf28b (diff) |
Replaced default python-requests user-agent with a custom ones (#54)
* Replaced default python-requests user-agent with a custom ones
This can improve analytics and QOS a bit
* isort
* made black happy
Diffstat (limited to 'cdsapi/api.py')
-rw-r--r-- | cdsapi/api.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cdsapi/api.py b/cdsapi/api.py index 68befdb..0211856 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -14,6 +14,7 @@ import os import time import uuid +import pkg_resources import requests try: @@ -324,6 +325,11 @@ class Client(object): self.session = session self.session.auth = tuple(self.key.split(":", 2)) + self.session.headers = { + "User-Agent": "cdsapi/%s" + % pkg_resources.get_distribution("cdsapi").version, + } + assert len(self.session.auth) == 2, ( "The cdsapi key provided is not the correct format, please ensure it conforms to:\n" "<UID>:<APIKEY>" |