From 493b80effeee0206c4e49d533efb7875ddd5ec0f Mon Sep 17 00:00:00 2001 From: Jeremy Cline Date: Apr 18 2025 16:39:31 +0000 Subject: Add a timeout to the bridge HTTP requests By default, the requests library does not add a timeout to HTTP requests. This can potentially cause the request to hang indefinitely. Switch to a timeout of 60 seconds on requests. This timeout applies to both the `connect()` and `read()` calls. Ref: https://docs.python-requests.org/en/latest/user/advanced/#timeouts --- diff --git a/src/bridge.py b/src/bridge.py index f7ecc1e..6d33548 100644 --- a/src/bridge.py +++ b/src/bridge.py @@ -177,7 +177,7 @@ def urlopen(url): Return (file, file size). Raise ForwardingError. ''' - r = requests.get(url, stream=True) # nosec + r = requests.get(url, stream=True, timeout=60.0) # nosec try: size = int(r.headers['content-length']) except KeyError: