summaryrefslogtreecommitdiffstats
path: root/yt_dlp/networking/common.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:10:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:10:22 +0000
commitbb3682b5a9a4d0e8e45f74de8c21dba3d5e6e0ab (patch)
treed7890656a89a7d2f3497a5793dd65aa746f7cabd /yt_dlp/networking/common.py
parentAdding upstream version 2024.04.09. (diff)
downloadyt-dlp-bb3682b5a9a4d0e8e45f74de8c21dba3d5e6e0ab.tar.xz
yt-dlp-bb3682b5a9a4d0e8e45f74de8c21dba3d5e6e0ab.zip
Adding upstream version 2024.05.26.upstream/2024.05.26
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp/networking/common.py')
-rw-r--r--yt_dlp/networking/common.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/yt_dlp/networking/common.py b/yt_dlp/networking/common.py
index 4c66ba6..d473e16 100644
--- a/yt_dlp/networking/common.py
+++ b/yt_dlp/networking/common.py
@@ -31,6 +31,8 @@ from ..utils import (
)
from ..utils.networking import HTTPHeaderDict, normalize_url
+DEFAULT_TIMEOUT = 20
+
def register_preference(*handlers: type[RequestHandler]):
assert all(issubclass(handler, RequestHandler) for handler in handlers)
@@ -235,7 +237,7 @@ class RequestHandler(abc.ABC):
self._logger = logger
self.headers = headers or {}
self.cookiejar = cookiejar if cookiejar is not None else YoutubeDLCookieJar()
- self.timeout = float(timeout or 20)
+ self.timeout = float(timeout or DEFAULT_TIMEOUT)
self.proxies = proxies or {}
self.source_address = source_address
self.verbose = verbose
@@ -497,6 +499,7 @@ class Response(io.IOBase):
@param headers: response headers.
@param status: Response HTTP status code. Default is 200 OK.
@param reason: HTTP status reason. Will use built-in reasons based on status code if not provided.
+ @param extensions: Dictionary of handler-specific response extensions.
"""
def __init__(
@@ -505,7 +508,9 @@ class Response(io.IOBase):
url: str,
headers: Mapping[str, str],
status: int = 200,
- reason: str = None):
+ reason: str = None,
+ extensions: dict = None
+ ):
self.fp = fp
self.headers = Message()
@@ -517,6 +522,7 @@ class Response(io.IOBase):
self.reason = reason or HTTPStatus(status).phrase
except ValueError:
self.reason = None
+ self.extensions = extensions or {}
def readable(self):
return self.fp.readable()