Skip to content

Commit

Permalink
use head for checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cccs-rs committed Jun 23, 2022
1 parent aacc08e commit c809134
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions urldownloader/urldownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def __init__(self, config) -> None:

def fetch_uri(self, uri: str, apply_filter: bool = True) -> str:
try:
resp = requests.get(uri, allow_redirects=True)
resp = requests.head(uri, allow_redirects=True, timeout=10)
# Only concerned with gathering responses of interest
if resp.ok:
if apply_filter and any(content_type in resp.headers.get('Content-Type')
for content_type in self.content_type_filter):
return
resp_fh = NamedTemporaryFile(delete=False)
resp_fh.write(resp.content)
resp_fh.write(requests.get(uri, allow_redirects=True).content)
resp_fh.close()
return resp_fh.name
except:
Expand Down

0 comments on commit c809134

Please sign in to comment.