/** * 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 is used to determine if the request method was HEAD. This * is of particular interest in a HTTP conversation as it tells * the response whether a response body is to be sent or not. * If the method is head the delimeters for the response should * be as they would be for a similar GET, however no body is sent. * * @return true if the request method was a HEAD method */ public boolean isHead() { String method = request.getMethod(); if(method != null) { return method.equalsIgnoreCase(HEAD); } return false; }
/** * The <code>isChunkable</code> method is used to determine if * the client supports chunked encoding. If the client does not * support chunked encoding then a connection close should be used * instead, this allows HTTP/1.0 clients to be supported properly. * * @return true if the client supports chunked transfer encoding */ public boolean isChunkable() { int major = request.getMajor(); int minor = request.getMinor(); if(major >= 1) { return minor >= 1; } 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; }
/** * The <code>isChunkable</code> method is used to determine if * the client supports chunked encoding. If the client does not * support chunked encoding then a connection close should be used * instead, this allows HTTP/1.0 clients to be supported properly. * * @return true if the client supports chunked transfer encoding */ public boolean isChunkable() { int major = request.getMajor(); int minor = request.getMinor(); if(major >= 1) { return minor >= 1; } 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; }
/** * The <code>isChunkable</code> method is used to determine if * the client supports chunked encoding. If the client does not * support chunked encoding then a connection close should be used * instead, this allows HTTP/1.0 clients to be supported properly. * * @return true if the client supports chunked transfer encoding */ public boolean isChunkable() { int major = request.getMajor(); int minor = request.getMinor(); if(major >= 1) { return minor >= 1; } return false; }
/** * This is used to determine if the method was a CONNECT. The * connect method is typically used when a client wishes to * establish a connection directly with an origin server. Such a * direct connection is useful when using TLS as it ensures there * is not man in the middle with respect to key exchanges. * * @return this returns true if the method was a CONNECT method */ public boolean isConnect() { String method = request.getMethod(); if(method != null) { return method.equalsIgnoreCase(CONNECT); } 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 is used to determine if the request method was HEAD. This * is of particular interest in a HTTP conversation as it tells * the response whether a response body is to be sent or not. * If the method is head the delimeters for the response should * be as they would be for a similar GET, however no body is sent. * * @return true if the request method was a HEAD method */ public boolean isHead() { String method = request.getMethod(); if(method != null) { return method.equalsIgnoreCase(HEAD); } return false; }
/** * This is used to determine if the method was a CONNECT. The * connect method is typically used when a client wishes to * establish a connection directly with an origin server. Such a * direct connection is useful when using TLS as it ensures there * is not man in the middle with respect to key exchanges. * * @return this returns true if the method was a CONNECT method */ public boolean isConnect() { String method = request.getMethod(); if(method != null) { return method.equalsIgnoreCase(CONNECT); } return false; }
/** * This is used to determine if the request method was HEAD. This * is of particular interest in a HTTP conversation as it tells * the response whether a response body is to be sent or not. * If the method is head the delimeters for the response should * be as they would be for a similar GET, however no body is sent. * * @return true if the request method was a HEAD method */ public boolean isHead() { String method = request.getMethod(); if(method == null) { return false; } return method.equalsIgnoreCase(HEAD); }