websocket_server_check_handshake


Description:


[ Version ( since = "2.50" ) ]
public bool websocket_server_check_handshake (Message msg, string? origin, string[]? protocols) throws Error

Examines the method and request headers in msg and determines whether msg contains a valid handshake request.

If origin is non-%NULL, then only requests containing a matching "Origin" header will be accepted. If protocols is non-%NULL, then only requests containing a compatible "Sec-WebSocket-Protocols" header will be accepted.

Requests containing "Sec-WebSocket-Extensions" header will be accepted even if the header is not valid. To check a request with extensions you need to use websocket_server_check_handshake_with_extensions and provide the list of supported extension types.

Normally websocket_server_process_handshake will take care of this for you, and if you use add_websocket_handler to handle accepting WebSocket connections, it will call that for you. However, this function may be useful if you need to perform more complicated validation; eg, accepting multiple different Origins, or handling different protocols depending on the path.

Parameters:

msg

Message containing the client side of a WebSocket handshake

origin

expected Origin header

protocols

allowed WebSocket protocols.

Returns:

true if msg contained a valid WebSocket handshake, false and an error if not.


Namespace: Soup
Package: libsoup-2.4