mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03:00
add timeout to net.http_get() and index.download_repo_index()
The requests docs recommend this: http://docs.python-requests.org/en/master/user/quickstart/#timeouts And mirror-monitor was hanging forever on a bad mirror.
This commit is contained in:
parent
9c900ed63c
commit
a2aef721d8
2 changed files with 5 additions and 5 deletions
|
|
@ -36,7 +36,7 @@ def download_file(url, local_filename=None, dldir='tmp'):
|
|||
return local_filename
|
||||
|
||||
|
||||
def http_get(url, etag=None):
|
||||
def http_get(url, etag=None, timeout=600):
|
||||
"""
|
||||
Downloads the content from the given URL by making a GET request.
|
||||
|
||||
|
|
@ -52,12 +52,12 @@ def http_get(url, etag=None):
|
|||
# TODO disable TLS Session IDs and TLS Session Tickets
|
||||
# (plain text cookie visible to anyone who can see the network traffic)
|
||||
if etag:
|
||||
r = requests.head(url, headers=headers)
|
||||
r = requests.head(url, headers=headers, timeout=timeout)
|
||||
r.raise_for_status()
|
||||
if 'ETag' in r.headers and etag == r.headers['ETag']:
|
||||
return None, etag
|
||||
|
||||
r = requests.get(url, headers=headers)
|
||||
r = requests.get(url, headers=headers, timeout=timeout)
|
||||
r.raise_for_status()
|
||||
|
||||
new_etag = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue