Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added test for repeating cookies in response headers#1385

Closed
scottsmith2gmail wants to merge 1 commit into
fastapi:masterfrom
scottsmith2gmail:repeated_cookies
Closed

Added test for repeating cookies in response headers#1385
scottsmith2gmail wants to merge 1 commit into
fastapi:masterfrom
scottsmith2gmail:repeated_cookies

Conversation

@scottsmith2gmail

Copy link
Copy Markdown
Contributor

Found this issue using fastapi. I haven't tracked down the cause. It seems every additional layer of redirection doubles the cookies in the header. No clue if this would actually break anything, but it seems like incorrect behavior at any rate.

@obataku

obataku commented May 7, 2020

Copy link
Copy Markdown
Contributor

the problem is that a call to solve_dependencies shares a single Response with its recursive calls for child dependencies, which may cause the original to have its headers.raw extended redundantly:

        solved_result = await solve_dependencies(
            ...
            response=response,
            ...
        )
        (
            ...
            sub_response,
            ...
        ) = solved_result
        sub_response = cast(Response, sub_response)
        response.headers.raw.extend(sub_response.headers.raw)
        if sub_response.status_code:
            response.status_code = sub_response.status_code

one obvious solution that comes to mind is to check whether sub_response is not response before using it to update response

@tiangolo

Copy link
Copy Markdown
Member

Thanks for discovering this and creating the tests @scottsmith2gmail ! 🕵️ 🐛 ✔️

I just merged the fix by @obataku including your tests, so we can close this one. 🚀

@tiangolo tiangolo closed this Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants