问题 I try to write a simple middleware for FastAPI peeking into response bodies. In this example I just log the body content: app = FastAPI() @app.middleware("http") async def log_request(request, call_next): logger.info(f'{request.method} {request.url}') response = await call_next(request) logger.info(f'Status code: {response.status_code}') async for line in response.body_iterator: logger.info(f' {line}') return response However it looks like I "consume" the body this way, resulting in this