Skip to content

Commit

Permalink
style: use predefined status code instead of raw in authentication mi…
Browse files Browse the repository at this point in the history
…ddleware
  • Loading branch information
snosratiershad committed Jan 21, 2025
1 parent 0109dce commit 1fd1a30
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion starlette/middleware/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
)
from starlette.requests import HTTPConnection
from starlette.responses import PlainTextResponse, Response
from starlette.status import WS_1000_NORMAL_CLOSURE
from starlette.types import ASGIApp, Receive, Scope, Send


Expand Down Expand Up @@ -37,7 +38,7 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
except AuthenticationError as exc:
response = self.on_error(conn, exc)
if scope["type"] == "websocket":
await send({"type": "websocket.close", "code": 1000})
await send({"type": "websocket.close", "code": WS_1000_NORMAL_CLOSURE})
else:
await response(scope, receive, send)
return
Expand Down

0 comments on commit 1fd1a30

Please sign in to comment.