Skip to content
Myr

Merge pull request #2299 from mattrobenolt/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Cap the redirect_cache size to prevent memory abuse

authored by Ian Cordasco · committed by Ian Cordasco · parents 1c52d15, 387c8f8 · Browse files · 1 file+3 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−1 removed

  • other:+3 added−1 removed

1 file+3 added−1 removed

modified:requests/sessions.py+3 added-1 removed
19 unmodified lines
20from .hooks import default_hooks, dispatch_hook21from .utils import to_key_val_list, default_headers, to_native_string22from .exceptions import (23 TooManyRedirects, InvalidSchema, ChunkedEncodingError, ContentDecodingError)24from .packages.urllib3._collections import RecentlyUsedContainer25from .structures import CaseInsensitiveDict2627from .adapters import HTTPAdapter28
298 unmodified lines
327 self.adapters = OrderedDict()328 self.mount('https://', HTTPAdapter())329 self.mount('http://', HTTPAdapter())330330 self.redirect_cache = {}331 # Only store 1000 redirects to prevent using infinite memory332 self.redirect_cache = RecentlyUsedContainer(1000)333334 def __enter__(self):335 return self336
337 unmodified lines