1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-26 16:58:28 +00:00

HTTP middleware create issues when streaming project archive

This commit is contained in:
grossmj 2022-06-01 15:31:59 +07:00
parent 940d22f2aa
commit 015e17338c

View File

@ -166,12 +166,14 @@ async def sqlalchemry_error_handler(request: Request, exc: SQLAlchemyError):
content={"message": "Database error detected, please check logs to find details"}, 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") # @app.middleware("http")
async def add_extra_headers(request: Request, call_next): # async def add_extra_headers(request: Request, call_next):
start_time = time.time() # start_time = time.time()
response = await call_next(request) # response = await call_next(request)
process_time = time.time() - start_time # process_time = time.time() - start_time
response.headers["X-Process-Time"] = str(process_time) # response.headers["X-Process-Time"] = str(process_time)
response.headers["X-GNS3-Server-Version"] = f"{__version__}" # response.headers["X-GNS3-Server-Version"] = f"{__version__}"
return response # return response