### Question:
WebSocketClientHandshaker07 extends WebSocketClientHandshaker { @Override protected FullHttpRequest newHandshakeRequest() { URI wsURL = uri(); String path = rawPath(wsURL); byte[] nonce = WebSocketUtil.randomBytes(16); String key = WebSocketUtil.base64(nonce); String acceptSeed = key + MAGIC_GUID; byte[] sha1 = WebSocketUtil.sha1(acceptSeed.getBytes(CharsetUtil.US_ASCII)); expectedChallengeResponseString = WebSocketUtil.base64(sha1); if (logger.isDebugEnabled()) { logger.debug( "WebSocket version 07 client handshake key: {}, expected response: {}", key, expectedChallengeResponseString); } int wsPort = websocketPort(wsURL); String host = wsURL.getHost(); FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path); HttpHeaders headers = request.headers(); headers.add(HttpHeaderNames.UPGRADE, HttpHeaderValues.WEBSOCKET) .add(HttpHeaderNames.CONNECTION, HttpHeaderValues.UPGRADE) .add(HttpHeaderNames.SEC_WEBSOCKET_KEY, key) .add(HttpHeaderNames.HOST, websocketHostValue(wsURL)) .add(HttpHeaderNames.SEC_WEBSOCKET_ORIGIN, websocketOriginValue(host, wsPort)); String expectedSubprotocol = expectedSubprotocol(); if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) { headers.add(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol); } headers.add(HttpHeaderNames.SEC_WEBSOCKET_VERSION, "7"); if (customHeaders != null) { headers.add(customHeaders); } return request; } WebSocketClientHandshaker07(URI webSocketURL, WebSocketVersion version, String subprotocol,
                                       boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength);  WebSocketClientHandshaker07(URI webSocketURL, WebSocketVersion version, String subprotocol,
            boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength,
            boolean performMasking, boolean allowMaskMismatch);  static final String MAGIC_GUID; }### Answer:
@Test public void testSecOriginWss() { URI uri = URI.create("wss: WebSocketClientHandshaker handshaker = newHandshaker(uri); FullHttpRequest request = handshaker.newHandshakeRequest(); try { assertEquals("https: } finally { request.release(); } }
@Test public void testSecOriginWs() { URI uri = URI.create("ws: WebSocketClientHandshaker handshaker = newHandshaker(uri); FullHttpRequest request = handshaker.newHandshakeRequest(); try { assertEquals("http: } finally { request.release(); } }