Soup.websocket_server_check_handshake
Description: Reference for Soup.websocket_server_check_handshake

### Function

# Soupwebsocket_server_check_handshake

#### Declaration [src]

    gboolean
    soup_websocket_server_check_handshake (
      SoupServerMessage* msg,
      const char* origin,
      char** protocols,
      GPtrArray* supported_extensions,
      GError** error
    )

#### Description [src]

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. If `supported_extensions` is non-`NULL`, then only requests containing valid supported extensions in “Sec-WebSocket-Extensions” header will be accepted.

Normally `soup_websocket_server_process_handshake()` will take care of this for you, and if you use `soup_server_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` | `SoupServerMessage`
| `SoupServerMessage` containing the client side of a WebSocket handshake.
| The data is owned by the caller of the function.
`origin` | `const char*`
| Expected Origin header.
| The argument can be `NULL`.
| The data is owned by the caller of the function.
| The value is a NUL terminated UTF-8 string.
`protocols` | An array of `char*`
| Allowed WebSocket protocols.
| The argument can be `NULL`.
| The array must be `NULL`-terminated.
| The data is owned by the caller of the function.
| Each element is a NUL terminated UTF-8 string.
`supported_extensions` | An array of `None`
| List of supported extension types.
| The argument can be `NULL`.
| The data is owned by the caller of the function.
`error` | `GError **`
| The return location for a `GError*`, or `NULL`.

#### Return value

Returns: | `gboolean`
| `TRUE` if `msg` contained a valid WebSocket handshake, `FALSE` and an error if not.