diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:10:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:10:24 +0000 |
commit | a0743e7d455e8e2e771bf834301e730f81d999a5 (patch) | |
tree | 679adb6bb9b3acc0fd4244063cf2863939cc36ac /yt_dlp/networking/common.py | |
parent | Releasing progress-linux version 2024.04.09-1~progress7.99u1. (diff) | |
download | yt-dlp-a0743e7d455e8e2e771bf834301e730f81d999a5.tar.xz yt-dlp-a0743e7d455e8e2e771bf834301e730f81d999a5.zip |
Merging upstream version 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.py | 10 |
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() |