From 015e17338c72776920f2c0382833e2e472c36ed4 Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 1 Jun 2022 15:31:59 +0700 Subject: [PATCH] HTTP middleware create issues when streaming project archive --- gns3server/api/server.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gns3server/api/server.py b/gns3server/api/server.py index 4c1c1b86..c3ceb816 100644 --- a/gns3server/api/server.py +++ b/gns3server/api/server.py @@ -166,12 +166,14 @@ async def sqlalchemry_error_handler(request: Request, exc: SQLAlchemyError): content={"message": "Database error detected, please check logs to find details"}, ) +# FIXME: do not use this middleware since it creates issue when using StreamingResponse +# see https://starlette-context.readthedocs.io/en/latest/middleware.html#why-are-there-two-middlewares-that-do-the-same-thing -@app.middleware("http") -async def add_extra_headers(request: Request, call_next): - start_time = time.time() - response = await call_next(request) - process_time = time.time() - start_time - response.headers["X-Process-Time"] = str(process_time) - response.headers["X-GNS3-Server-Version"] = f"{__version__}" - return response +# @app.middleware("http") +# async def add_extra_headers(request: Request, call_next): +# start_time = time.time() +# response = await call_next(request) +# process_time = time.time() - start_time +# response.headers["X-Process-Time"] = str(process_time) +# response.headers["X-GNS3-Server-Version"] = f"{__version__}" +# return response