Is it possible to register a connection adapter to multiple prefixes using Python requests.Session?

Viewed 117

Is it possible register an Adapter to both http and https like:

from requests import Session
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

session = Session()
retries = Retry(total=5, backoff_factor=1, status_forcelist=[403, 404, 502, 503, 504])
session.mount("http", HTTPAdapter(max_retries=retries))

session.get(api_url)

or do I need to register individually for both?

from requests import Session
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

session = Session()
retries = Retry(total=5, backoff_factor=1, status_forcelist=[403, 404, 502, 503, 504])
session.mount("http://", HTTPAdapter(max_retries=retries))
session.mount("https://", HTTPAdapter(max_retries=retries))

session.get(api_url)
0 Answers
Related