Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D4C87200AF6 for ; Sat, 11 Jun 2016 13:13:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D394E160A1A; Sat, 11 Jun 2016 11:13:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 26775160A34 for ; Sat, 11 Jun 2016 13:13:21 +0200 (CEST) Received: (qmail 73768 invoked by uid 500); 11 Jun 2016 11:13:21 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 73545 invoked by uid 99); 11 Jun 2016 11:13:21 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Jun 2016 11:13:21 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id EBEF42C1F5C for ; Sat, 11 Jun 2016 11:13:20 +0000 (UTC) Date: Sat, 11 Jun 2016 11:13:20 +0000 (UTC) From: "Tom Fitzhenry (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HTTPCORE-422) HttpAsyncRequestExecutor#responseReceived calls HttpAsyncResponseConsumer#responseReceived(HttpResponse), even for HEAD requests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sat, 11 Jun 2016 11:13:23 -0000 [ https://issues.apache.org/jira/browse/HTTPCORE-422?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15325817#comment-15325817 ] Tom Fitzhenry commented on HTTPCORE-422: ---------------------------------------- Sorry, you're right: not calling #responseReceived would be a bad idea. The problem is that BasicAsyncResponseConsumer#responseReceived allocates a 4kB buffer for the response entity, even if the request is a HEAD request (and hence will have no response entity). This is unnecessary allocation. There are two things that could be done to avoid this: (a) BasicAsyncResponseConsumer could allocate in onContentReceived (which presumably is not called for HEAD responses, and hence no response entity allocation would occur for HEAD responses), OR (b) Users should not use BasicAsyncResponseConsumer for HEAD requests, and instead should use a response consumer that does not allocate a response entity. (e.g. the NoopResponseConsumer I listed above). I'm currently doing (b), which I'm happy to do, but (a) would benefit all users of Apache HttpAsyncClient that use BasicAsyncResponseConsumer with HEAD requests. > HttpAsyncRequestExecutor#responseReceived calls HttpAsyncResponseConsumer#responseReceived(HttpResponse), even for HEAD requests > -------------------------------------------------------------------------------------------------------------------------------- > > Key: HTTPCORE-422 > URL: https://issues.apache.org/jira/browse/HTTPCORE-422 > Project: HttpComponents HttpCore > Issue Type: Improvement > Components: HttpCore NIO > Affects Versions: 4.4.4 > Reporter: Tom Fitzhenry > Assignee: Oleg Kalnichevski > Priority: Minor > > HttpAsyncRequestExecutor#responseReceived(NHttpClientConnection) calls HttpAsyncResponseConsumer#responseReceived(HttpResponse) via HttpAsyncClientExchangeHandler#responseReceived(HttpResponse). > See https://github.com/apache/httpcore/blob/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java#L302 . > It does this even if the request is a HEAD request. If your HttpAsyncResponseConsumer is a BasicAsyncResponseConsumer, then this will allocate a buffer of size content-length kB (or 4kB, if content-length does not exist). > For a simple proxying Java app, profiling revealed this the allocation due to this was a bottleneck. > It'd be nice if > Are there use cases for calling HttpAsyncResponseConsumer#responseReceived(HttpResponse) on HEAD requests? If not, perhaps it could not be called. > FWIW, it looks like httpclient doe not call the corresponding method for HEAD requests: https://github.com/apache/httpcore/blob/4.4.x/httpcore/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java#L273-L275 -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org