Open joeytrapp opened 3 days ago
@joeytrapp thanks for opening this issue!
Yeah, the conn
should be automatically recycled when we make another endpoint request. But, we currently don't have an option to pass headers into that, and we don't copy them.
And since recyle/1
only recycles "accept", "accept-language", and "authorization" by default, I can see why that'd be a problem if you have custom headers.
A question for you: do you know if there's a danger in copying all the request headers from one request to the next? I'll do some digging myself, but I wanted to double check that we wouldn't be breaking things or creating behavior the browser doesn't have (leading your tests to pass but prod to be broken).
The only case I can think up for not wanting the request headers to always all be copied would be if the initial request had some specialized headers that subsequent requests wouldn't have when the browser followed a redirect. This case wouldn't affect us, so I don't have a specific scenario.
We encounted a problem where the request headers set before the initial visit/2 are not present in subsequent redirects. Could there be a configuration that always copies request headers to the next request, or a way to inject a before redirect callback that could allow us to modify the conn ahead of time. Also there is an option for
Phoenix.ConnTest.recycle/2
that instructs which request headers to carry forward when recycling the conn, so it would be great to have a way to set that option. https://hexdocs.pm/phoenix/Phoenix.ConnTest.html#recycle/2Linked is a gist using phoenix_playground that demonstrates a failure case. https://gist.github.com/joeytrapp/35c984a67cf2eb6eb0f6f4b3ef9e060f