Websockets - Headers

Godot Version

4.5.1

Question

I have 2 questions.

When trying to connect to a non-godot server using the websocket protocol, Bruno (a web request testing tool) connects cleanly, showing 4 response headers for the connection. When trying to connect via godot, I see the error: "Not enough response headers. Got: 2 expected >= 4.”
from the C++ below:

bool WSLPeer::_verify_server_response() {
Vector psa = String::ascii(Span((const char *)handshake_buffer->get_data_array().ptr(), handshake_buffer->get_position() - 4)).split(“\r\n”);
int len = psa.size();
ERR_FAIL_COND_V_MSG(len < 4, false, "Not enough response headers. Got: " + itos(len) + “, expected >= 4.”);

Why is it looking for 4 headers? I don’t believe Godot is even inspecting the headers, making the connector look like it’s in a rough shape.

Bruno shows:

sec-websocket-version 13
upgrade websocket
connection upgrade
sec-websocket-accept LFD5WwPt8F0iIaAdKzy33SIaZSs=

Is it possible the websocket implementation isn’t parsing the headers properly?

Adding additional headers to the initial connection response, still shows the same error.

access-control-allow-origin *
access-control-allow-credentials true

Adding CORS headers (now there’s 5 headers), also did not help. Same error.

Bruno is more lenient and assumes/adds missing headers to the UI. The Godot implementation does look for 3 specific headers that comply strictly with RFC 6455 and a protocol switch header, which is a special case? - in total, what amounts to 4 headers. The >=4 header requirement is a post-processing check, with no further parsing (since it was all done earlier).

I had the server properly send the required headers, with the correct case and the protocol switch header and the connection behaved as I expected.