vinissimus / async-asgi-testclient

A framework-agnostic library for testing ASGI web applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request `Cookie` header is invalid

druid8 opened this issue · comments

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.