MCPcopy Create free account
hub / github.com/aria2/aria2 / createWebSocketServerKey

Function createWebSocketServerKey

src/HttpServerCommand.cc:125–133  ·  view source on GitHub ↗

Creates server's WebSocket accept key which will be sent in Sec-WebSocket-Accept header field. The |clientKey| is the value found in Sec-WebSocket-Key header field in the request.

Source from the content-addressed store, hash-verified

123// Sec-WebSocket-Accept header field. The |clientKey| is the value
124// found in Sec-WebSocket-Key header field in the request.
125std::string createWebSocketServerKey(const std::string& clientKey)
126{
127 std::string src = clientKey;
128 src += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
129 unsigned char digest[20];
130 message_digest::digest(digest, sizeof(digest), MessageDigest::sha1().get(),
131 src.c_str(), src.size());
132 return base64::encode(&digest[0], &digest[sizeof(digest)]);
133}
134} // namespace
135
136namespace {

Callers 1

executeMethod · 0.85

Calls 5

digestFunction · 0.85
encodeFunction · 0.70
sha1Function · 0.50
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected