mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31:15 -07:00
Bump requests from 2.27.1 to 2.28.1 (#1781)
* Bump requests from 2.27.1 to 2.28.1 Bumps [requests](https://github.com/psf/requests) from 2.27.1 to 2.28.1. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](https://github.com/psf/requests/compare/v2.27.1...v2.28.1) --- updated-dependencies: - dependency-name: requests dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update requests==2.28.1 * Update urllib3==1.26.12 * Update certifi==2022.9.24 * Update idna==3.4 * Update charset-normalizer==2.1.1 Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
baa0e08c2a
commit
af1aed0b6b
46 changed files with 3295 additions and 2709 deletions
|
@ -2,6 +2,7 @@ from __future__ import absolute_import
|
|||
|
||||
import io
|
||||
import logging
|
||||
import sys
|
||||
import zlib
|
||||
from contextlib import contextmanager
|
||||
from socket import error as SocketError
|
||||
|
@ -15,6 +16,7 @@ try:
|
|||
except ImportError:
|
||||
brotli = None
|
||||
|
||||
from . import util
|
||||
from ._collections import HTTPHeaderDict
|
||||
from .connection import BaseSSLError, HTTPException
|
||||
from .exceptions import (
|
||||
|
@ -481,6 +483,54 @@ class HTTPResponse(io.IOBase):
|
|||
if self._original_response and self._original_response.isclosed():
|
||||
self.release_conn()
|
||||
|
||||
def _fp_read(self, amt):
|
||||
"""
|
||||
Read a response with the thought that reading the number of bytes
|
||||
larger than can fit in a 32-bit int at a time via SSL in some
|
||||
known cases leads to an overflow error that has to be prevented
|
||||
if `amt` or `self.length_remaining` indicate that a problem may
|
||||
happen.
|
||||
|
||||
The known cases:
|
||||
* 3.8 <= CPython < 3.9.7 because of a bug
|
||||
https://github.com/urllib3/urllib3/issues/2513#issuecomment-1152559900.
|
||||
* urllib3 injected with pyOpenSSL-backed SSL-support.
|
||||
* CPython < 3.10 only when `amt` does not fit 32-bit int.
|
||||
"""
|
||||
assert self._fp
|
||||
c_int_max = 2 ** 31 - 1
|
||||
if (
|
||||
(
|
||||
(amt and amt > c_int_max)
|
||||
or (self.length_remaining and self.length_remaining > c_int_max)
|
||||
)
|
||||
and not util.IS_SECURETRANSPORT
|
||||
and (util.IS_PYOPENSSL or sys.version_info < (3, 10))
|
||||
):
|
||||
buffer = io.BytesIO()
|
||||
# Besides `max_chunk_amt` being a maximum chunk size, it
|
||||
# affects memory overhead of reading a response by this
|
||||
# method in CPython.
|
||||
# `c_int_max` equal to 2 GiB - 1 byte is the actual maximum
|
||||
# chunk size that does not lead to an overflow error, but
|
||||
# 256 MiB is a compromise.
|
||||
max_chunk_amt = 2 ** 28
|
||||
while amt is None or amt != 0:
|
||||
if amt is not None:
|
||||
chunk_amt = min(amt, max_chunk_amt)
|
||||
amt -= chunk_amt
|
||||
else:
|
||||
chunk_amt = max_chunk_amt
|
||||
data = self._fp.read(chunk_amt)
|
||||
if not data:
|
||||
break
|
||||
buffer.write(data)
|
||||
del data # to reduce peak memory usage by `max_chunk_amt`.
|
||||
return buffer.getvalue()
|
||||
else:
|
||||
# StringIO doesn't like amt=None
|
||||
return self._fp.read(amt) if amt is not None else self._fp.read()
|
||||
|
||||
def read(self, amt=None, decode_content=None, cache_content=False):
|
||||
"""
|
||||
Similar to :meth:`http.client.HTTPResponse.read`, but with two additional
|
||||
|
@ -513,13 +563,11 @@ class HTTPResponse(io.IOBase):
|
|||
fp_closed = getattr(self._fp, "closed", False)
|
||||
|
||||
with self._error_catcher():
|
||||
data = self._fp_read(amt) if not fp_closed else b""
|
||||
if amt is None:
|
||||
# cStringIO doesn't like amt=None
|
||||
data = self._fp.read() if not fp_closed else b""
|
||||
flush_decoder = True
|
||||
else:
|
||||
cache_content = False
|
||||
data = self._fp.read(amt) if not fp_closed else b""
|
||||
if (
|
||||
amt != 0 and not data
|
||||
): # Platform-specific: Buggy versions of Python.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue