Closed tkellogg closed 2 years ago
Ah, there's still a problem with this — the cookies set by redirects still aren't set in the final response object. Gonna need a bit more work
A bit of sleuthing shows this behavior is implemented by all major browsers, so it seems like we should support it: https://blog.dubbelboer.com/2012/11/25/302-cookie.html
Looks like some unrelated rubocop failures. I thought we had rubocop pinned to prevent that...
@tarcieri This is ready now, as far as I'm concerned. Let me know if anything needs fixing
@tkellogg some rubocop failures
I think these are fixed by the rubocop update?
Aah nope, oh well. #718 fixes them
I have some plans of removing redirector as is, and introducing session object instead. Session will be a http client wrapper that will hold cookies. This PR has these lines:
# I wish we could just do @response.cookes = cookie_jar
cookie_jar.each do |cookie|
@response.cookies.add(cookie)
end
I believe this is wrong and comes from the idea of using redirector as a session. The response should not hold cookie jar of previous requests.
A Session
type to encapsulate this state would be great. See also #306.
When a redirect response arrives, the browser will recognize
Set-Cookie
headers the same as any other request/response. This PR enables the Redirector to correctly follow the cookie hand-offs.I encountered this situation out in the wild. This PR, as-is, seems to fix the issue. I haven't bothered to find the relevant spec.