MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / computeAccept

Method computeAccept

Libraries/Http/HttpWebSocket.cpp:396–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394}
395
396Result HttpWebSocketHandshake::computeAccept(StringSpan clientKey, Span<char> storage, StringSpan& accept)
397{
398 SC_TRY(validateClientKey(clientKey));
399
400 HttpWebSocketSha1 sha1;
401 SC_TRY(
402 sha1.add(Span<const uint8_t>::reinterpret_bytes(clientKey.bytesWithoutTerminator(), clientKey.sizeInBytes())));
403 SC_TRY(sha1.add({reinterpret_cast<const uint8_t*>(SC_HTTP_WEBSOCKET_GUID), sizeof(SC_HTTP_WEBSOCKET_GUID) - 1}));
404
405 uint8_t digest[20] = {0};
406 SC_TRY(sha1.finish(digest));
407 return scHttpWebSocketBase64Encode({digest, sizeof(digest)}, storage, accept);
408}
409
410bool HttpWebSocketHandshake::headerContainsToken(StringSpan headerValue, StringSpan token)
411{

Callers

nothing calls this directly

Calls 5

reinterpret_bytesFunction · 0.85
addMethod · 0.45
sizeInBytesMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected