Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FollowRedirects middleware: copy opts from response env
Middlewares that come after FollowRedirects might use `opts` for state they need to keep if they are called multiple times. The specific use case we have that requires this: Our pool for gun requires explicit checkout/checkin of the connection. We have a middleware after FollowRedirects that checks out a connection, passes it to adapter opts, requests and then checks the connection back in. However, if `body_as: :chunks` options is used, we, obviously, can't checkin the connection in the middleware as it needs to be passed to the client after leaving the middleware. But if there was a redirect to a different host we want to checkin the old connection and checkout a new one ourselves. So we want to check if adapter options already have a connection in them and checkin it if present.
- Loading branch information