diff options
author | liris <liris.pp@gmail.com> | 2019-12-25 21:25:11 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-25 21:25:11 +0900 |
commit | 8aee28a761503e0e92c5fd6e39676d0d834ffb3f (patch) | |
tree | 7400237a0bbcdcc81ea364899e04b08e7af574e7 | |
parent | 6d1434230510323a43691009b1d0aa3f8a6df132 (diff) | |
parent | 32c6d41bf0677b6c3147d144724831691eb7fd8a (diff) | |
download | websocket-client-8aee28a761503e0e92c5fd6e39676d0d834ffb3f.tar.gz |
Merge pull request #553 from spacewander/improve_readability
Improve the readability of HTTP status codes.
-rw-r--r-- | websocket/_handshake.py | 5 |
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) |