Closed LiraNuna closed 1 year ago
This is because you are using the ASGI client:
Unlike the SanicTestClient that spins up a server on every request, the SanicASGITestClient does not. Instead it makes use of the httpx library to execute Sanic as an ASGI application to reach inside and execute the route handlers.
If you do not manually add a header like content-length
, then the server does this for you. This is why you see it if you use test_client
instead of asgi_client
. In that case, Sanic server does run and does add the header.
When using asgi_client
there is no server. And, in an actual ASGI setup your ASGI server would be adding that header.
It seems as though sanic_testing does not full expose the final response.
When running the same server and making a request to it, the
Content-Length
header is correctly set:I would like to add that
Content-Type
is the only response header sent as well, soTransfer-Encoding
is not set either.