You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a Requests Session with an HTTPAdapter with urllib3.util.Retry configuration supplied, when the adapter is bound to an empty string prefix (""), the retries don't execute.
Expected Result
This was an attempt to set up a session where every request in the session would have the retries executed, regardless of the prefix. A glance at the Requests Session source code seems to indicate this should work... the empty string can be a key in the OrderedDict storing the Session's adapters, and checking url.startswith("") should return True. However...
Actual Result
The retry configuration is ignored, and you're given a Response object with the erroneous error code instead of a raised requests.exceptions.RetryError. When binding the Adapter to the session with an actual prefix (for example, "https://"), the Retry behavior is observed.
Reproduction Steps
The below script can be run to show the behavior, and below that I've posted the output I receive from it.
The text was updated successfully, but these errors were encountered:
matthewarmand
changed the title
Retries don't work a session adapter with empty prefix ("")
Retries don't work using a session adapter with empty prefix ("")
Sep 21, 2023
That makes sense, thanks. This is one area of requests where the documentation could be much clearer. Would it be appropriate to continue extending the Advanced Usage section I added in #6258 (https://requests.readthedocs.io/en/latest/user/advanced/#example-automatic-retries) with some of these additional details/gotchas? Or would it be better to start a different place in the docs for more in-depth documentation?
When using a Requests
Session
with anHTTPAdapter
withurllib3.util.Retry
configuration supplied, when the adapter is bound to an empty string prefix (""
), the retries don't execute.Expected Result
This was an attempt to set up a session where every request in the session would have the retries executed, regardless of the prefix. A glance at the Requests
Session
source code seems to indicate this should work... the empty string can be a key in theOrderedDict
storing theSession
's adapters, and checkingurl.startswith("")
should returnTrue
. However...Actual Result
The retry configuration is ignored, and you're given a
Response
object with the erroneous error code instead of a raisedrequests.exceptions.RetryError
. When binding the Adapter to the session with an actual prefix (for example,"https://"
), the Retry behavior is observed.Reproduction Steps
The below script can be run to show the behavior, and below that I've posted the output I receive from it.
Results:
System Information
The text was updated successfully, but these errors were encountered: