mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-16 10:49:36 +00:00
Ignore a subprotocol the WebSocket client did not offer
A SubProtocolSelector could return a value outside the client's Sec-WebSocket-Protocol list, and the server sent it back as is. The server now treats such a value as no selection.
This commit is contained in:
1 parent
4fcbc08f2d
commit
6d1049462d
3 files changed
+31
-1
No files matched your search
@@ -14692,6 +14692,12 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
|
||||
protocols.emplace_back(b, e);
|
||||
});
|
||||
selected_subprotocol = entry.sub_protocol_selector(protocols);
|
||||
|
||||
// Ignore a selection the client did not offer (RFC 6455 4.2.2)
|
||||
if (std::find(protocols.begin(), protocols.end(),
|
||||
selected_subprotocol) == protocols.end()) {
|
||||
selected_subprotocol.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user