diff options
author | spacewander <spacewanderlzx@gmail.com> | 2019-05-10 18:22:21 +0800 |
---|---|---|
committer | spacewander <spacewanderlzx@gmail.com> | 2019-05-10 18:22:21 +0800 |
commit | 32c6d41bf0677b6c3147d144724831691eb7fd8a (patch) | |
tree | 9dd51cd59a95242d11ca18c272369505685d3890 | |
parent | 3c25814664fef5b78716ed8841123ed1c0d17824 (diff) | |
download | websocket-client-32c6d41bf0677b6c3147d144724831691eb7fd8a.tar.gz |
Improve the readability of HTTP status codes.
This commit also changes the type of 'SUPPORTED_REDIRECT_STATUSES' to
'tuple'. It seems that this change doesn't break anything.
-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 809a8c9..a088bb0 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() @@ -154,7 +155,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) |