Skip to content

Commit

Permalink
fix: Update requests methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kovalch committed Feb 2, 2024
1 parent 34bdc35 commit e9b6cf0
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 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,24 @@ 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,
},
stream=True, # Data is downloaded in smaller chunks
)
req.raise_for_status()
log.info("sent response %s" % req.status_code)
except requests.exceptions.HTTPError as e:
Expand Down

0 comments on commit e9b6cf0

Please sign in to comment.