Изменения мидлваре
This commit is contained in:
parent
4efdd1d091
commit
4dc2fc58b1
1 changed files with 2 additions and 2 deletions
|
@ -46,9 +46,9 @@ app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
||||||
|
|
||||||
class AddHeaderMiddleware(BaseHTTPMiddleware):
|
class AddHeaderMiddleware(BaseHTTPMiddleware):
|
||||||
async def dispatch(self, request: Request, call_next):
|
async def dispatch(self, request: Request, call_next):
|
||||||
logging.critical(f"Запрос \n{request.headers["Sec-Websocket-Protocol"]}")
|
logging.critical(f"Запрос \n{request.headers.get("Sec-Websocket-Protocol", "НИХУЯ")}")
|
||||||
response = await call_next(request)
|
response = await call_next(request)
|
||||||
logging.critical(f"Ответ \n {response.headers["Sec-Websocket-Protocol"]}")
|
logging.critical(f"Ответ \n {response.headers.get("Sec-Websocket-Protocol", "НИХУЯ")}")
|
||||||
if "Sec-Websocket-Protocol" in request.headers:
|
if "Sec-Websocket-Protocol" in request.headers:
|
||||||
raise ValueError(request.headers["Sec-Websocket-Protocol"])
|
raise ValueError(request.headers["Sec-Websocket-Protocol"])
|
||||||
response.headers["Sec-Websocket-Protocol"] = request.headers["Sec-Websocket-Protocol"]
|
response.headers["Sec-Websocket-Protocol"] = request.headers["Sec-Websocket-Protocol"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue