getWebSocketSignatureKeyOrThrow static method

String getWebSocketSignatureKeyOrThrow(
  1. Request request
)

Returns web socket signature key.

If the Request does not contain the Sec-WebSocket-Key header, then it will throw a SpryHttpException.badRequest.

Implementation

static String getWebSocketSignatureKeyOrThrow(Request request) {
  final key = request.headers.value('sec-websocket-key');
  if (key == null) {
    throw SpryHttpException.badRequest(
      message: 'Missing Sec-WebSocket-Key header.',
    );
  }

  return WebSocketChannel.signKey(key);
}