-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve response body when retrying/redirecting
This is another iteration in our redirect/retry response body handling. Previously, when the response body is streamed, we ensured only the "final" response body is the one written to the user-provided stream. The only issue is that sometimes it can be helpful to have access to the intermediate response bodies that ended up being retried/redirected. This PR refactors the `readbody` machinery a bit to ensure we always read the response body, and in the case of a user-provided response stream, we read the response body as a string and store it in the request context. One motivation I'm working towards with this is providing more nuanced control over the retry logic, even allowing users to pass in their own `check` function to determine if a request should be retried or not based on the failed response. In that scenario, you'll want access to the failed response body, so this will enabled that.
- Loading branch information
Showing
2 changed files
with
24 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters