Added check for HTTP version and GET method when upgrading WebSocket to comply with RFC 6455. (#23332)

This commit is contained in:
Kuwazy 2025-03-25 15:00:50 +01:00 committed by GitHub
parent e1c6af2840
commit 6b6dc1cd3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,6 +23,11 @@ pub fn init(
send_buffer: []u8,
recv_buffer: []align(4) u8,
) InitError!bool {
switch (request.head.version) {
.@"HTTP/1.0" => return false,
.@"HTTP/1.1" => if (request.head.method != .GET) return false,
}
var sec_websocket_key: ?[]const u8 = null;
var upgrade_websocket: bool = false;
var it = request.iterateHeaders();