private static int getWebSocketContentLength(HttpMessage message) {
        // WebSocket messages have constant content-lengths.
        HttpHeaders h = message.headers();
        if (message instanceof HttpRequest) {
            HttpRequest req = (HttpRequest) message;
            if (HttpMethod.GET.equals(req.method()) &&
                    h.contains(HttpHeaderNames.SEC_WEBSOCKET_KEY1) &&
                    h.contains(HttpHeaderNames.SEC_WEBSOCKET_KEY2)) {
                return 8;
            }
        } else if (message instanceof HttpResponse) {
            HttpResponse res = (HttpResponse) message;
            if (res.status().code() == 101 &&
                    h.contains(HttpHeaderNames.SEC_WEBSOCKET_ORIGIN) &&
                    h.contains(HttpHeaderNames.SEC_WEBSOCKET_LOCATION)) {
                return 16;
            }
        }

        // Not a web socket message
        return -1;
    }
private static int getWebSocketContentLength ( HttpMessage message ) { HttpHeaders h = message . headers ( ) ; if ( message instanceof HttpRequest ) { HttpRequest req = ( HttpRequest ) message ; if ( HttpMethod . GET . equals ( req . method ( ) ) && h . contains ( HttpHeaderNames . SEC_WEBSOCKET_KEY1 ) && h . contains ( HttpHeaderNames . SEC_WEBSOCKET_KEY2 ) ) { return 8 ; } } else if ( message instanceof HttpResponse ) { HttpResponse res = ( HttpResponse ) message ; if ( res . status ( ) . code ( ) == 101 && h . contains ( HttpHeaderNames . SEC_WEBSOCKET_ORIGIN ) && h . contains ( HttpHeaderNames . SEC_WEBSOCKET_LOCATION ) ) { return 16 ; } } return - 1 ; }
Returns the content length of the specified web socket message. If the
specified message is not a web socket message, {@code -1} is returned.