wpiutil: WebSocket: Fix Sec-Websocket-Accept computation

It needs to use the raw SHA1 bytes, not the hex-decoded text.
This commit is contained in:
Peter Johnson
2018-11-18 18:27:06 -08:00
parent 75cc3cda28
commit e4aa45f34b
3 changed files with 4 additions and 3 deletions

View File

@@ -223,6 +223,7 @@ TEST_F(WebSocketTest, CreateServerBasic) {
ASSERT_EQ(value, "Upgrade");
++gotConnection;
} else if (name.equals_lower("sec-websocket-accept")) {
ASSERT_EQ(value, "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=");
++gotAccept;
} else {
FAIL() << "unexpected header " << name.str();
@@ -232,7 +233,7 @@ TEST_F(WebSocketTest, CreateServerBasic) {
serverPipe->Listen([&]() {
auto conn = serverPipe->Accept();
auto ws = WebSocket::CreateServer(*conn, "foo", "13");
auto ws = WebSocket::CreateServer(*conn, "dGhlIHNhbXBsZSBub25jZQ==", "13");
ws->open.connect([&](StringRef protocol) {
++gotOpen;
ASSERT_TRUE(protocol.empty());