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`

  Type: `SoupServerMessage`

  `SoupServerMessage` containing the client side of a WebSocket handshake.

  The data is owned by the caller of the function.

`origin`

  Type: `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`

  Type: 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`

  Type: 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`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will left initialized to `NULL` by the function if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `gboolean`

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