HomePhorge
Diffusion tesla 3a2789d8535f

FollowRedirects middleware: copy opts from response env

Description

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.

Details

Provenance
rinpatchAuthored on Sep 4 2020, 4:23 AM
Parents
R28:dbe88cec4306: Merge pull request #412 from wingyplus/fix-warning-tests
Branches
Unknown
Tags
Unknown
References
fix/redirect-middleware-ignores-env

Event Timeline