First Check
Commit to Help
Example Code
from fastapi import FastAPI, Request, Response
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
class Middleware(BaseHTTPMiddleware):
async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) -> Response:
await request.json()
response = await call_next(request)
return response
app = FastAPI()
app.add_middleware(Middleware)
@app.post("/test")
async def test(test: dict) -> dict:
return {"data": "test"}
Description
- Run script with:
uvicorn main:app --reload
- Run CURL with POST request:
curl -X 'POST' 'http://localhost:8000/test' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"test": "test"}'
The application keeps hanging indefinitely and don't send a response to the request. I tested the equivalent code using app = Starlette() and it answers correctly.
Operating System
Linux
Operating System Details
Ubuntu 22.04
FastAPI Version
0.79.0
Python Version
Python 3.10.4
Additional Context
No response
First Check
Commit to Help
Example Code
Description
uvicorn main:app --reloadcurl -X 'POST' 'http://localhost:8000/test' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"test": "test"}'The application keeps hanging indefinitely and don't send a response to the request. I tested the equivalent code using
app = Starlette()and it answers correctly.Operating System
Linux
Operating System Details
Ubuntu 22.04
FastAPI Version
0.79.0
Python Version
Python 3.10.4
Additional Context
No response