Skip to content

Commit 8c05981

Browse files
authored
Remove use of method_whitelist when possible (#532)
Deprecated in favor of allowed_methods. Fall back to the old argument for older versions of urllib3 which do not support the new one. Uses conditional attribute check as recommended in urllib3/urllib3#2057
1 parent b35abb9 commit 8c05981

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

firebase_admin/_http_client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@
2222
from requests.packages.urllib3.util import retry # pylint: disable=import-error
2323

2424

25-
_ANY_METHOD = None
26-
25+
if hasattr(retry.Retry.DEFAULT, 'allowed_methods'):
26+
_ANY_METHOD = {'allowed_methods': None}
27+
else:
28+
_ANY_METHOD = {'method_whitelist': None}
2729
# Default retry configuration: Retries once on low-level connection and socket read errors.
2830
# Retries up to 4 times on HTTP 500 and 503 errors, with exponential backoff. Returns the
2931
# last response upon exhausting all retries.
3032
DEFAULT_RETRY_CONFIG = retry.Retry(
31-
connect=1, read=1, status=4, status_forcelist=[500, 503], method_whitelist=_ANY_METHOD,
32-
raise_on_status=False, backoff_factor=0.5)
33+
connect=1, read=1, status=4, status_forcelist=[500, 503],
34+
raise_on_status=False, backoff_factor=0.5, **_ANY_METHOD)
3335

3436

3537
DEFAULT_TIMEOUT_SECONDS = 120

0 commit comments

Comments
 (0)