throw new OpeningHandshakeException( WebSocketError.NO_CONNECTION_HEADER, "The opening handshake response does not contain 'Connection' header.", throw new OpeningHandshakeException( WebSocketError.NO_UPGRADE_IN_CONNECTION_HEADER, "'Upgrade' was not found in 'Connection' header.",
StatusLine sl = e.getStatusLine(); LOGGER.info("=== Status Line ==="); LOGGER.info("HTTP Version = \n" + sl.getHttpVersion()); Map<String, List<String>> headers = e.getHeaders(); LOGGER.info("=== HTTP Headers ==="); for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
throw new OpeningHandshakeException( WebSocketError.NO_UPGRADE_HEADER, "The opening handshake response does not contain 'Upgrade' header.", throw new OpeningHandshakeException( WebSocketError.NO_WEBSOCKET_IN_UPGRADE_HEADER, "'websocket' was not found in 'Upgrade' header.",
throw new OpeningHandshakeException( WebSocketError.NO_SEC_WEBSOCKET_ACCEPT_HEADER, "The opening handshake response does not contain 'Sec-WebSocket-Accept' header.", throw new OpeningHandshakeException( WebSocketError.UNEXPECTED_SEC_WEBSOCKET_ACCEPT_HEADER, "The value of 'Sec-WebSocket-Accept' header is different from the expected one.",
/** * 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); }
private void validateExtensionCombination( StatusLine statusLine, Map<String, List<String>> headers, List<WebSocketExtension> extensions) throws WebSocketException { // Currently, only duplication of per-message compression extensions is checked. // A per-message compression extension found in the list. WebSocketExtension pmce = null; for (WebSocketExtension extension : extensions) { // If the extension is not a per-message compression extension. if ((extension instanceof PerMessageCompressionExtension) == false) { continue; } // If the found per-message compression extension is the first one. if (pmce == null) { // Found a per-message compression extension. pmce = extension; continue; } // Found the second per-message compression extension. Conflict. String message = String.format( "'%s' extension and '%s' extension conflict with each other.", pmce.getName(), extension.getName()); // The extensions conflict with each other. throw new OpeningHandshakeException( WebSocketError.EXTENSIONS_CONFLICT, message, statusLine, headers); } }
throw new OpeningHandshakeException( WebSocketError.UNSUPPORTED_PROTOCOL, "The protocol contained in the Sec-WebSocket-Protocol header is not supported: " + protocol,
throw new OpeningHandshakeException( WebSocketError.EXTENSION_PARSE_ERROR, "The value in 'Sec-WebSocket-Extensions' failed to be parsed: " + element, throw new OpeningHandshakeException( WebSocketError.UNSUPPORTED_EXTENSION, "The extension contained in the Sec-WebSocket-Extensions header is not supported: " + name,
throw new OpeningHandshakeException( WebSocketError.NO_UPGRADE_HEADER, "The opening handshake response does not contain 'Upgrade' header.", throw new OpeningHandshakeException( WebSocketError.NO_WEBSOCKET_IN_UPGRADE_HEADER, "'websocket' was not found in 'Upgrade' header.",
throw new OpeningHandshakeException( WebSocketError.NO_CONNECTION_HEADER, "The opening handshake response does not contain 'Connection' header.", throw new OpeningHandshakeException( WebSocketError.NO_UPGRADE_IN_CONNECTION_HEADER, "'Upgrade' was not found in 'Connection' header.",
throw new OpeningHandshakeException( WebSocketError.NO_SEC_WEBSOCKET_ACCEPT_HEADER, "The opening handshake response does not contain 'Sec-WebSocket-Accept' header.", throw new OpeningHandshakeException( WebSocketError.UNEXPECTED_SEC_WEBSOCKET_ACCEPT_HEADER, "The value of 'Sec-WebSocket-Accept' header is different from the expected one.",
/** * 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); }
private void validateExtensionCombination( StatusLine statusLine, Map<String, List<String>> headers, List<WebSocketExtension> extensions) throws WebSocketException { // Currently, only duplication of per-message compression extensions is checked. // A per-message compression extension found in the list. WebSocketExtension pmce = null; for (WebSocketExtension extension : extensions) { // If the extension is not a per-message compression extension. if ((extension instanceof PerMessageCompressionExtension) == false) { continue; } // If the found per-message compression extension is the first one. if (pmce == null) { // Found a per-message compression extension. pmce = extension; continue; } // Found the second per-message compression extension. Conflict. String message = String.format( "'%s' extension and '%s' extension conflict with each other.", pmce.getName(), extension.getName()); // The extensions conflict with each other. throw new OpeningHandshakeException( WebSocketError.EXTENSIONS_CONFLICT, message, statusLine, headers); } }
throw new OpeningHandshakeException( WebSocketError.UNSUPPORTED_PROTOCOL, "The protocol contained in the Sec-WebSocket-Protocol header is not supported: " + protocol,
throw new OpeningHandshakeException( WebSocketError.EXTENSION_PARSE_ERROR, "The value in 'Sec-WebSocket-Extensions' failed to be parsed: " + element, throw new OpeningHandshakeException( WebSocketError.UNSUPPORTED_EXTENSION, "The extension contained in the Sec-WebSocket-Extensions header is not supported: " + name,