// Create the WebSocket handshake response.
HttpResponse res = new DefaultHttpResponse(
HTTP_1_1,
new HttpResponseStatus(101, "Web Socket Protocol Handshake"));
res.addHeader(Names.UPGRADE, WEBSOCKET);
res.addHeader(CONNECTION, Values.UPGRADE);
// Fill in the headers and contents depending on handshake method.
if (request.containsHeader(SEC_WEBSOCKET_KEY1) &&
request.containsHeader(SEC_WEBSOCKET_KEY2)) {
// New handshake method with a challenge: