/** * This is used to determine if a WebSocket upgrade was requested * and established. An upgrade to use a WebSocket is done when the * client requests the upgrade and the server responds with an * upgrade confirmation, this is the basic handshake required. * * @return this returns true if a WebSocket handshake succeeded */ public boolean isWebSocket() { String token = request.getValue(UPGRADE); int code = response.getCode(); if(token != null && code == 101) { String reply = response.getValue(UPGRADE); if(token.equalsIgnoreCase(WEBSOCKET)) { return token.equalsIgnoreCase(reply); } } return false; }
/** * This is used to determine if a WebSocket upgrade was requested * and established. An upgrade to use a WebSocket is done when the * client requests the upgrade and the server responds with an * upgrade confirmation, this is the basic handshake required. * * @return this returns true if a WebSocket handshake succeeded */ public boolean isWebSocket() { String token = request.getValue(UPGRADE); int code = response.getCode(); if(token != null && code == 101) { String reply = response.getValue(UPGRADE); if(token.equalsIgnoreCase(WEBSOCKET)) { return token.equalsIgnoreCase(reply); } } return false; }
/** * This checks the protocol version used in the request to check * whether it supports persistent HTTP connections. By default the * HTTP/1.1 protocol supports persistent connnections, this can * onlyy be overridden with a Connection header with the close * token. Earlier protocol versions are connection close. * * @return this returns true if the protocol is HTTP/1.1 or above */ public boolean isPersistent() { String token = request.getValue(CONNECTION); if(token != null) { return token.equalsIgnoreCase(KEEP_ALIVE); } int major = request.getMajor(); int minor = request.getMinor(); if(major > 1) { return true; } if(major == 1) { return minor > 0; } return false; }
/** * This checks the protocol version used in the request to check * whether it supports persistent HTTP connections. By default the * HTTP/1.1 protocol supports persistent connnections, this can * onlyy be overridden with a Connection header with the close * token. Earlier protocol versions are connection close. * * @return this returns true if the protocol is HTTP/1.1 or above */ public boolean isPersistent() { String token = request.getValue(CONNECTION); if(token != null) { return token.equalsIgnoreCase(KEEP_ALIVE); } int major = request.getMajor(); int minor = request.getMinor(); if(major > 1) { return true; } if(major == 1) { return minor > 0; } return false; }
/** * This checks the protocol version used in the request to check * whether it supports persistent HTTP connections. By default the * HTTP/1.1 protocol supports persistent connnections, this can * onlyy be overridden with a Connection header with the close * token. Earlier protocol versions are connection close. * * @return this returns true if the protocol is HTTP/1.1 or above */ public boolean isPersistent() { String token = request.getValue(CONNECTION); if(token != null) { return token.equalsIgnoreCase(KEEP_ALIVE); } int major = request.getMajor(); int minor = request.getMinor(); if(major > 1) { return true; } if(major == 1) { return minor > 0; } return false; }