Skip to content

Commit

Permalink
Adds gwosc version to user-agent in http headers
Browse files Browse the repository at this point in the history
  • Loading branch information
martinberoiz authored and duncanmmacleod committed Apr 20, 2023
1 parent 474a423 commit 1170515
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gwosc/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import os
import re
from urllib.parse import urlencode
from . import __version__

import requests

Expand Down Expand Up @@ -61,7 +62,8 @@ def fetch_json(url, **kwargs):
return JSON_CACHE[url]
except KeyError:
logger.debug("fetching {}".format(url))
resp = requests.get(url, **kwargs)
client_headers = {"User-Agent": f"python-gwosc/{__version__}"}
resp = requests.get(url, headers=client_headers, **kwargs)
resp.raise_for_status()
return JSON_CACHE.setdefault(
url,
Expand Down

0 comments on commit 1170515

Please sign in to comment.