From dev-return-202816-archive-asf-public=cust-asf.ponee.io@tomcat.apache.org Thu Oct 24 14:53:06 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id A388D18065D for ; Thu, 24 Oct 2019 16:53:06 +0200 (CEST) Received: (qmail 93760 invoked by uid 500); 24 Oct 2019 14:53:05 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 93750 invoked by uid 99); 24 Oct 2019 14:53:05 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Oct 2019 14:53:05 +0000 From: GitBox To: dev@tomcat.apache.org Subject: [GitHub] [tomcat] michael-o commented on a change in pull request #218: WIP: BZ 63835: Add support for Keep-Alive header Message-ID: <157192878528.3494.16603025527152741718.gitbox@gitbox.apache.org> Date: Thu, 24 Oct 2019 14:53:05 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit michael-o commented on a change in pull request #218: WIP: BZ 63835: Add support for Keep-Alive header URL: https://github.com/apache/tomcat/pull/218#discussion_r338621248 ########## File path: java/org/apache/coyote/http11/Http11Processor.java ########## @@ -915,8 +915,26 @@ protected final void prepareResponse() throws IOException { headers.addValue(Constants.CONNECTION).setString( Constants.CLOSE); } - } else if (!http11 && !getErrorState().isError()) { - headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE); + } else if (!getErrorState().isError()) { + if (!http11) { + headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE); + } + + boolean connectionKeepAlivePresent = + isConnectionToken(request.getMimeHeaders(), Constants.KEEPALIVE); + + if (connectionKeepAlivePresent) { + int keepAliveTimeout = protocol.getKeepAliveTimeout(); + + if (keepAliveTimeout > 0) { + String value = "timeout=" + keepAliveTimeout / 1000L; + headers.setValue("Keep-Alive").setString(value); + } + + if (http11) { + headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE); Review comment: @markt-asf This is is a very good question. I share @ChristopherSchultz's opinion. It is in line with https://tools.ietf.org/id/draft-thomson-hybi-http-timeout-01.html#rfc.section.2. If the client has not requested a keep alive, the else clause is never evaluated. The condition is that the has send a `keep-alive` and either a timeout is set or the timeout is negative which means the connection can be held open forever. Does this make sense? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org