Crow
Crow copied to clipboard
Websocket Close Frame Doesn't Contain Status Code
Per https://www.rfc-editor.org/rfc/rfc6455#section-5.5.1, when a websocket connection is closed, if the closing frame contains a body it should also contain a 2-byte 'closing status code'.
Currently, the code in question (https://github.com/CrowCpp/Crow/blob/master/include/crow/websocket.h#L169) just accepts a 'msg' parameter, but according to the RFC the signature for this function should be something like void close(uint16_t code, std::string const& reason)
With the current implementation, the first two bytes of the msg string are interpreted as the closing code and are missing from the reason string, as interpreted by standards-compliant implementations (like web browsers).