#32159: AsyncTestClient does not allow setting request headers as documented for
TestClient via HTTP_* kwargs
-------------------------------------+-------------------------------------
Reporter: Ryan | Owner: nobody
Vinzent |
Type: Bug | Status: new
Component: Testing | Version: 3.1
framework | Keywords: AsyncTestClient,
Severity: Normal | AsyncRequestFactory
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
In the test client documentation, it states
>CGI specification
>
>The headers sent via `**extra` should follow CGI specification. For
example, emulating a different “Host” header as sent in the HTTP request
from the browser to the server should be passed as `HTTP_HOST`.
This simply does not work for `AsyncTestClient`, even though the
documentation states the async client should behave the same as the
regular test client.
This somehow works to assign a request header:
{{{
client = AsyncTestClient(HTTP_AUTHORIZATION="Bearer faketoken")
await client.get("/api/my-endpoint")
}}}
but this does not work:
{{{
client = AsyncTestClient()
await client.get("/api/my-endpoint", HTTP_AUTHORIZATION="Bearer
faketoken")
}}}
Both of these examples work with the normal `Client` so they should also
work with the `AsyncClient` as is documented.
--
Ticket URL: <https://code.djangoproject.com/ticket/32159>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.ce46a69e40af6a328486d11a2d7c0fb9%40djangoproject.com.