Closed ncraike closed 7 years ago
The omission of a reason phrase is always valid, that's not debatable. Reason-Phrase = *<TEXT, excluding CR, LF>
. *
is a sequence of tokens and there's no minimum defined. The space after the status code is required though.
Okay. That may be the case, but I think both server and client implementations are going to have to be tolerant of some non-standard behaviour.
Sure, it this case it's fine, as adding it doesn't break the spec.
During the initial connection handshake, a server typically responds to the upgrade request with a response like:
However, if the server omits the human-readable text after the
HTTP/1.1 101
(conventionally "Switching Protocols"), thewebsockets.connect
call throws an exception like this:I understand it's debatable as to whether omitting the human-readable text (the "reason phrase") is valid for a server, but I think in the interests of working with different WebSockets server implementations, the client should accept the HTTP response even if the "reason phrase" is omitted, and not throw an exception.
RFC6455 Section 4.2.2 mentions the status line of the server response during the handshake, but directs the reader to RFC2616 (HTTP/1.1 ) for a full definition.
RFC2616 Section 6.1 describes the "status line" of a response including the human-readable message, described as a "reason phrase".
For reference:
The above exception was thrown on my laptop running macOS 10.11.6 (El Capitan) and Homebrew-installed Python 3.5, with
websockets
installed in a virtualenv. Output from pip: