Dependencies:
- fastapi 0.73.0
- starlette 0.17.1
- pydantic 1.9.0
- h11 0.12.0
Traceback
When trying to open http://localhost:XXXX/docs
:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 364, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 212, in __call__
await super().__call__(scope, receive, send)
File "/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 181, in __call__
raise exc
File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 64, in __call__
await response(scope, receive, send)
File "/usr/local/lib/python3.9/site-packages/starlette/responses.py", line 244, in __call__
await wrap(partial(self.listen_for_disconnect, receive))
File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 574, in __aexit__
raise exceptions[0]
File "/usr/local/lib/python3.9/site-packages/starlette/responses.py", line 240, in wrap
await func()
File "/usr/local/lib/python3.9/site-packages/starlette/responses.py", line 234, in stream_response
await send({"type": "http.response.body", "body": b"", "more_body": False})
File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 156, in _send
await send(message)
File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 468, in send
output = self.conn.send(event)
File "/usr/local/lib/python3.9/site-packages/h11/_connection.py", line 468, in send
data_list = self.send_with_data_passthrough(event)
File "/usr/local/lib/python3.9/site-packages/h11/_connection.py", line 501, in send_with_data_passthrough
writer(event, data_list.append)
File "/usr/local/lib/python3.9/site-packages/h11/_writers.py", line 60, in __call__
self.send_eom(event.headers, write)
File "/usr/local/lib/python3.9/site-packages/h11/_writers.py", line 83, in send_eom
raise LocalProtocolError("Too little data for declared Content-Length")
h11._util.LocalProtocolError: Too little data for declared Content-Length
The issue (I think)
https://github.com/mongkok/fastapi-debug-toolbar/blob/3552b0bbb8e1a86a4f5eaaf214e6916d52c941ef/debug_toolbar/middleware.py#L84
On first iteration, body
equals the correct body from response (b'<HTML CONTENT>'
), on second iteration body
is empty (b''
). This empty body is use on the subsequent code, inserted on response, but line 97 never occurs.