boolean isGracefullyFinishResponseOnClose() { final HttpResponsePacket response = responsePacket; return response != null && !response.getProcessingState().isKeepAlive() && !response.isChunked() && response.getContentLength() == -1; }
boolean isGracefullyFinishResponseOnClose() { final HttpResponsePacket response = responsePacket; return response != null && !response.getProcessingState().isKeepAlive() && !response.isChunked() && response.getContentLength() == -1; }
boolean isGracefullyFinishResponseOnClose() { final HttpResponsePacket response = responsePacket; return response != null && !response.getProcessingState().isKeepAlive() && !response.isChunked() && response.getContentLength() == -1; }
boolean isGracefullyFinishResponseOnClose() { final HttpResponsePacket response = responsePacket; return response != null && !response.getProcessingState().isKeepAlive() && !response.isChunked() && response.getContentLength() == -1; }
boolean isGracefullyFinishResponseOnClose() { final HttpResponsePacket response = responseStatus.getResponse(); return !response.getProcessingState().isKeepAlive() && !response.isChunked() && response.getContentLength() == -1; }
/** * Send the next part of the response * * @throws java.io.IOException */ public void sendResponse() throws IOException { if (!contentSend) { contentSend = true; isDone = !httpResponsePacket.isChunked(); ctx.write(httpResponseContent, this); return; } isDone = true; ctx.write(httpResponsePacket.httpTrailerBuilder().build(), this); }
/** * Send the next part of the response * * @throws java.io.IOException */ public void sendResponse() throws IOException { if (!contentSend) { contentSend = true; isDone = httpResponsePacket.getRequest().getMethod().equals(HEAD) || !httpResponsePacket.isChunked(); ctx.write(httpResponseContent, this); return; } isDone = true; ctx.write(httpResponsePacket.httpTrailerBuilder().build(), this); }
/** * Method gets called, when file chunk was successfully sent. * * @param result the result */ @Override public void completed(WriteResult result) { try { if (!isDone) { sendInputStreamChunk(); // In HTTP 1.0 (no chunk supported) there is no more data sent to the client after the input stream is completed. // As there is no more data to be sent (in HTTP 1.1 a last chunk with '0' is sent) the #completed method is not called // So, we have to call it manually here if (isDone && !httpResponsePacket.isChunked()) { doComplete(); } } else { doComplete(); } } catch (IOException e) { failed(e); } }
if (isDone && !httpResponsePacket.isChunked())
private static boolean checkKeepAlive(final HttpResponsePacket response) { final int statusCode = response.getStatus(); final boolean isExpectContent = response.isExpectContent(); boolean keepAlive = !statusDropsConnection(statusCode) || (!isExpectContent || !response.isChunked() || response.getContentLength() == -1); // double-check the transfer encoding here if (keepAlive) { // Check the Connection header final DataChunk cVal = response.getHeaders().getValue(Header.Connection); if (response.getProtocol().compareTo(Protocol.HTTP_1_1) < 0) { // HTTP 1.0 response // "Connection: keep-alive" should be specified explicitly keepAlive = cVal != null && cVal.equalsIgnoreCase(KEEPALIVE_BYTES); } else { // HTTP 1.1+ // keep-alive by default, if there's no "Connection: close" keepAlive = cVal == null || !cVal.equalsIgnoreCase(CLOSE_BYTES); } } return keepAlive; }
private static boolean checkKeepAlive(final HttpResponsePacket response) { final int statusCode = response.getStatus(); final boolean isExpectContent = response.isExpectContent(); boolean keepAlive = !statusDropsConnection(statusCode) || (!isExpectContent || !response.isChunked() || response.getContentLength() == -1); // double-check the transfer encoding here if (keepAlive) { // Check the Connection header final DataChunk cVal = response.getHeaders().getValue(Header.Connection); if (response.getProtocol().compareTo(Protocol.HTTP_1_1) < 0) { // HTTP 1.0 response // "Connection: keep-alive" should be specified explicitly keepAlive = cVal != null && cVal.equalsIgnoreCase(KEEPALIVE_BYTES); } else { // HTTP 1.1+ // keep-alive by default, if there's no "Connection: close" keepAlive = cVal == null || !cVal.equalsIgnoreCase(CLOSE_BYTES); } } return keepAlive; }
private static boolean checkKeepAlive(final HttpResponsePacket response) { final int statusCode = response.getStatus(); final boolean isExpectContent = response.isExpectContent(); boolean keepAlive = !statusDropsConnection(statusCode) || (!isExpectContent || !response.isChunked() || response.getContentLength() == -1); // double-check the transfer encoding here if (keepAlive) { // Check the Connection header final DataChunk cVal = response.getHeaders().getValue(Header.Connection); if (response.getProtocol().compareTo(Protocol.HTTP_1_1) < 0) { // HTTP 1.0 response // "Connection: keep-alive" should be specified explicitly keepAlive = cVal != null && cVal.equalsIgnoreCase(KEEPALIVE_BYTES); } else { // HTTP 1.1+ // keep-alive by default, if there's no "Connection: close" keepAlive = cVal == null || !cVal.equalsIgnoreCase(CLOSE_BYTES); } } return keepAlive; }
private static boolean checkKeepAlive(final HttpResponsePacket response) { final int statusCode = response.getStatus(); final boolean isExpectContent = response.isExpectContent(); boolean keepAlive = !statusDropsConnection(statusCode) || (!isExpectContent || !response.isChunked() || response.getContentLength() == -1); // double-check the transfer encoding here if (keepAlive) { // Check the Connection header final DataChunk cVal = response.getHeaders().getValue(Header.Connection); if (response.getProtocol().compareTo(Protocol.HTTP_1_1) < 0) { // HTTP 1.0 response // "Connection: keep-alive" should be specified explicitly keepAlive = cVal != null && cVal.equalsIgnoreCase(KEEPALIVE_BYTES); } else { // HTTP 1.1+ // keep-alive by default, if there's no "Connection: close" keepAlive = cVal == null || !cVal.equalsIgnoreCase(CLOSE_BYTES); } } return keepAlive; }
private static boolean checkKeepAlive(final HttpResponsePacket response) { final int statusCode = response.getStatus(); final boolean isExpectContent = response.isExpectContent(); boolean keepAlive = !statusDropsConnection(statusCode) || (!isExpectContent || !response.isChunked() || response.getContentLength() == -1); // double-check the transfer encoding here if (keepAlive) { // Check the Connection header final DataChunk cVal = response.getHeaders().getValue(Header.Connection); if (response.getProtocol().compareTo(Protocol.HTTP_1_1) < 0) { // HTTP 1.0 response // "Connection: keep-alive" should be specified explicitly keepAlive = cVal != null && cVal.equalsIgnoreCase(KEEPALIVE_BYTES); } else { // HTTP 1.1+ // keep-alive by default, if there's no "Connection: close" keepAlive = cVal == null || !cVal.equalsIgnoreCase(CLOSE_BYTES); } } return keepAlive; }
private static boolean checkKeepAlive(final HttpResponsePacket response) { final int statusCode = response.getStatus(); final boolean isExpectContent = response.isExpectContent(); boolean keepAlive = !statusDropsConnection(statusCode) || (!isExpectContent || !response.isChunked() || response.getContentLength() == -1); // double-check the transfer encoding here if (keepAlive) { // Check the Connection header final DataChunk cVal = response.getHeaders().getValue(Header.Connection); if (response.getProtocol().compareTo(Protocol.HTTP_1_1) < 0) { // HTTP 1.0 response // "Connection: keep-alive" should be specified explicitly keepAlive = cVal != null && cVal.equalsIgnoreCase(KEEPALIVE_BYTES); } else { // HTTP 1.1+ // keep-alive by default, if there's no "Connection: close" keepAlive = cVal == null || !cVal.equalsIgnoreCase(CLOSE_BYTES); } } return keepAlive; }
private static boolean checkKeepAlive(final HttpResponsePacket response) { final int statusCode = response.getStatus(); final boolean isExpectContent = response.isExpectContent(); boolean keepAlive = !statusDropsConnection(statusCode) || (!isExpectContent || !response.isChunked() || response.getContentLength() == -1); // double-check the transfer encoding here if (keepAlive) { // Check the Connection header final DataChunk cVal = response.getHeaders().getValue(Header.Connection); if (response.getProtocol().compareTo(Protocol.HTTP_1_1) < 0) { // HTTP 1.0 response // "Connection: keep-alive" should be specified explicitly keepAlive = cVal != null && cVal.equalsIgnoreCase(KEEPALIVE_BYTES); } else { // HTTP 1.1+ // keep-alive by default, if there's no "Connection: close" keepAlive = cVal == null || !cVal.equalsIgnoreCase(CLOSE_BYTES); } } return keepAlive; }
private static boolean checkKeepAlive(final HttpResponsePacket response) { final int statusCode = response.getStatus(); final boolean isExpectContent = response.isExpectContent(); boolean keepAlive = !statusDropsConnection(statusCode) || (!isExpectContent || !response.isChunked() || response.getContentLength() == -1); // double-check the transfer encoding here if (keepAlive) { // Check the Connection header final DataChunk cVal = response.getHeaders().getValue(Header.Connection); if (response.getProtocol().compareTo(Protocol.HTTP_1_1) < 0) { // HTTP 1.0 response // "Connection: keep-alive" should be specified explicitly keepAlive = cVal != null && cVal.equalsIgnoreCase(KEEPALIVE_BYTES); } else { // HTTP 1.1+ // keep-alive by default, if there's no "Connection: close" keepAlive = cVal == null || !cVal.equalsIgnoreCase(CLOSE_BYTES); } } return keepAlive; }
private static boolean checkKeepAlive(final HttpResponsePacket response) { final int statusCode = response.getStatus(); final boolean isExpectContent = response.isExpectContent(); boolean keepAlive = !statusDropsConnection(statusCode) || (!isExpectContent || !response.isChunked() || response.getContentLength() == -1); // double-check the transfer encoding here if (keepAlive) { // Check the Connection header final DataChunk cVal = response.getHeaders().getValue(Header.Connection); if (response.getProtocol().compareTo(Protocol.HTTP_1_1) < 0) { // HTTP 1.0 response // "Connection: keep-alive" should be specified explicitly keepAlive = cVal != null && cVal.equalsIgnoreCase(KEEPALIVE_BYTES); } else { // HTTP 1.1+ // keep-alive by default, if there's no "Connection: close" keepAlive = cVal == null || !cVal.equalsIgnoreCase(CLOSE_BYTES); } } return keepAlive; }
private static boolean checkKeepAlive(final HttpResponsePacket response) { final int statusCode = response.getStatus(); final boolean isExpectContent = response.isExpectContent(); boolean keepAlive = !statusDropsConnection(statusCode) || (!isExpectContent || !response.isChunked() || response.getContentLength() == -1); // double-check the transfer encoding here if (keepAlive) { // Check the Connection header final DataChunk cVal = response.getHeaders().getValue(Header.Connection); if (response.getProtocol().compareTo(Protocol.HTTP_1_1) < 0) { // HTTP 1.0 response // "Connection: keep-alive" should be specified explicitly keepAlive = cVal != null && cVal.equalsIgnoreCase(KEEPALIVE_BYTES); } else { // HTTP 1.1+ // keep-alive by default, if there's no "Connection: close" keepAlive = cVal == null || !cVal.equalsIgnoreCase(CLOSE_BYTES); } } return keepAlive; }
if (!protocol.equals(HTTP_1_0) && !httpResponsePacket.isChunked() && !hasContentLength) { httpResponsePacket.setContentLength(bytes.length);