Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request Cookie header is invalid #41

Closed
druid8 opened this issue Dec 13, 2021 · 0 comments · Fixed by #42
Closed

Request Cookie header is invalid #41

druid8 opened this issue Dec 13, 2021 · 0 comments · Fixed by #42

Comments

@druid8
Copy link
Contributor

druid8 commented Dec 13, 2021

Cookies from cookie jar are rendered in wrong way into Cookie request header. The HTTP request Cookie header should contain only cookie_name=cookie_value pairs delimited by semicolon (;). Currently whole cookie is rendered as for response Set-Cookie which cause than tested application sees cookies like Expires, Domain, Samesite etc...
Moreover if more than one cookie is in cookie jar, generated header makes whole request malformed as rendered cookies are \r\n separated (which obviously ends request's Cookie header at first occurrence and the rest are rubbish)

issue is here: async_asgi_testclient/testing.py:

        if cookie_jar and cookie_jar.output(header=""):
            headers.add("Cookie", cookie_jar.output(header=""))

I will make a PR with a fix soon.

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 a pull request may close this issue.

1 participant