Skip to content

Commit

Permalink
Merge pull request #54 from opendata-swiss/fix_requests_methods
Browse files Browse the repository at this point in the history
Update requests methods
  • Loading branch information
kovalch authored Feb 2, 2024
2 parents 34bdc35 + 367d3c3 commit eb25df1
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions ckan_pkg_checker/utils/request_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@ def check_url_status(test_url, http_method="HEAD"):
"Chrome/55.0.2883.75 "
"Safari/537.36"
)
req = session.request(
http_method,
test_url,
verify=False,
timeout=30,
headers={"User-Agent": user_agent},
stream=True, # data is downloaded in smaller chunks
)
if http_method == "HEAD":
req = requests.head(
test_url,
verify=False, # SSL certificate will not be verified
timeout=30,
headers={"User-Agent": user_agent},
)
elif http_method == "GET":
req = requests.get(
test_url,
verify=False, # SSL certificate will not be verified
timeout=30,
headers={
"Range": "bytes=0-10", # Request the first 10 bytes
"User-Agent": user_agent,
},
)
req.raise_for_status()
log.info("sent response %s" % req.status_code)
except requests.exceptions.HTTPError as e:
Expand Down

0 comments on commit eb25df1

Please sign in to comment.