summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliris <liris.pp@gmail.com>2019-12-25 21:25:11 +0900
committerGitHub <noreply@github.com>2019-12-25 21:25:11 +0900
commit8aee28a761503e0e92c5fd6e39676d0d834ffb3f (patch)
tree7400237a0bbcdcc81ea364899e04b08e7af574e7
parent6d1434230510323a43691009b1d0aa3f8a6df132 (diff)
parent32c6d41bf0677b6c3147d144724831691eb7fd8a (diff)
downloadwebsocket-client-8aee28a761503e0e92c5fd6e39676d0d834ffb3f.tar.gz
Merge pull request #553 from spacewander/improve_readability
Improve the readability of HTTP status codes.
-rw-r--r--websocket/_handshake.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/websocket/_handshake.py b/websocket/_handshake.py
index 3ff5147..4650c55 100644
--- a/websocket/_handshake.py
+++ b/websocket/_handshake.py
@@ -55,7 +55,8 @@ else:
# websocket supported version.
VERSION = 13
-SUPPORTED_REDIRECT_STATUSES = [HTTPStatus.MOVED_PERMANENTLY, HTTPStatus.FOUND, HTTPStatus.SEE_OTHER]
+SUPPORTED_REDIRECT_STATUSES = (HTTPStatus.MOVED_PERMANENTLY, HTTPStatus.FOUND, HTTPStatus.SEE_OTHER,)
+SUCCESS_STATUSES = SUPPORTED_REDIRECT_STATUSES + (HTTPStatus.SWITCHING_PROTOCOLS,)
CookieJar = SimpleCookieJar()
@@ -157,7 +158,7 @@ def _get_handshake_headers(resource, host, port, options):
return headers, key
-def _get_resp_headers(sock, success_statuses=(101, 301, 302, 303)):
+def _get_resp_headers(sock, success_statuses=SUCCESS_STATUSES):
status, resp_headers, status_message = read_headers(sock)
if status not in success_statuses:
raise WebSocketBadStatusException("Handshake status %d %s", status, status_message, resp_headers)