# upgrade method

Future<WebSocket> upgrade (HttpRequest request, { dynamic protocolSelector(List<String> protocols), CompressionOptions compression: CompressionOptions.compressionDefault })

Upgrades a HttpRequest to a WebSocket connection. If the request is not a valid WebSocket upgrade request an HTTP response with status code 500 will be returned. Otherwise the returned future will complete with the WebSocket when the upgrade process is complete.

If `protocolSelector` is provided, `protocolSelector` will be called to select what protocol to use, if any were provided by the client. `protocolSelector` is should return either a String or a Future completing with a String. The String must exist in the list of protocols.

If `compression` is provided, the WebSocket created will be configured to negotiate with the specified CompressionOptions. If none is specified then the WebSocket will be created with the default CompressionOptions.

## Implementation

    static Future<WebSocket> upgrade(HttpRequest request,
        {protocolSelector(List<String> protocols),
        CompressionOptions compression: CompressionOptions.compressionDefault}) {
      return _WebSocketTransformerImpl._upgrade(
          request, protocolSelector, compression);
    }