String message = "HTTP/1.1 101 Switching Protocols\r\n" +
"Upgrade: websocket\r\n" +
"Connection: Upgrade\r\n" +
"Sec-WebSocket-Accept: " +
new UTF8String(secWebSocketKey).concat(new UTF8String("258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))
.toSHA1().toBase64().toString() +
"\r\n" +
"\r\n";
return new UTF8String(message).array();
} catch (UnsupportedEncodingException e) {
throw new WebSocketException("UTF-8 charset not available", e);
} catch (NoSuchAlgorithmException e) {
throw new WebSocketException("SHA-1 hashing not available.", e);
}