/** * Validate the status line. {@code "101 Switching Protocols"} is expected. */ private void validateStatusLine(StatusLine statusLine, Map<String, List<String>> headers, WebSocketInputStream input) throws WebSocketException { // If the status code is 101 (Switching Protocols). if (statusLine.getStatusCode() == 101) { // OK. The server can speak the WebSocket protocol. return; } // Read the response body. byte[] body = readBody(headers, input); // The status code of the opening handshake response is not Switching Protocols. throw new OpeningHandshakeException( WebSocketError.NOT_SWITCHING_PROTOCOLS, "The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: " + statusLine, statusLine, headers, body); }
return new StatusLine(line);
LOGGER.info("HTTP Version = \n" + sl.getHttpVersion()); LOGGER.info("Status Code = \n" + sl.getStatusCode()); LOGGER.info("Reason Phrase = \n" + sl.getReasonPhrase());
/** * Validate the status line. {@code "101 Switching Protocols"} is expected. */ private void validateStatusLine(StatusLine statusLine, Map<String, List<String>> headers, WebSocketInputStream input) throws WebSocketException { // If the status code is 101 (Switching Protocols). if (statusLine.getStatusCode() == 101) { // OK. The server can speak the WebSocket protocol. return; } // Read the response body. byte[] body = readBody(headers, input); // The status code of the opening handshake response is not Switching Protocols. throw new OpeningHandshakeException( WebSocketError.NOT_SWITCHING_PROTOCOLS, "The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: " + statusLine, statusLine, headers, body); }
return new StatusLine(line);