Skip to content

Commit

Permalink
Merge pull request #55 from opendata-swiss/use-custom-user-agent
Browse files Browse the repository at this point in the history
Use generic user agent
  • Loading branch information
kovalch authored Feb 2, 2024
2 parents eb25df1 + ac2862f commit 89b1f0d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions ckan_pkg_checker/utils/request_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@ def check_url_status(test_url, http_method="HEAD"):
log.debug("URL %s (%s)" % (test_url, http_method))
error_result = None
try:
user_agent = (
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/55.0.2883.75 "
"Safari/537.36"
)
if http_method == "HEAD":
req = requests.head(
test_url,
verify=False, # SSL certificate will not be verified
timeout=30,
headers={"User-Agent": user_agent},
headers={"User-Agent": "Custom"},
)
elif http_method == "GET":
req = requests.get(
Expand All @@ -38,7 +32,7 @@ def check_url_status(test_url, http_method="HEAD"):
timeout=30,
headers={
"Range": "bytes=0-10", # Request the first 10 bytes
"User-Agent": user_agent,
"User-Agent": "Custom",
},
)
req.raise_for_status()
Expand Down

0 comments on commit 89b1f0d

Please sign in to comment.