Return-Path: Delivered-To: apmail-hc-dev-archive@www.apache.org Received: (qmail 83296 invoked from network); 8 Sep 2010 17:10:43 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Sep 2010 17:10:43 -0000 Received: (qmail 78074 invoked by uid 500); 8 Sep 2010 17:10:42 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 77916 invoked by uid 500); 8 Sep 2010 17:10:42 -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 77906 invoked by uid 99); 8 Sep 2010 17:10:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Sep 2010 17:10:41 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [217.72.192.227] (HELO fmmailgate02.web.de) (217.72.192.227) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Sep 2010 17:10:34 +0000 Received: from smtp04.web.de ( [172.20.0.225]) by fmmailgate02.web.de (Postfix) with ESMTP id F2BE616FB52B4 for ; Wed, 8 Sep 2010 19:10:12 +0200 (CEST) Received: from [193.5.154.224] (helo=[193.5.154.224]) by smtp04.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #4) id 1OtOA0-00049s-00 for dev@hc.apache.org; Wed, 08 Sep 2010 19:10:12 +0200 Message-ID: <4C87C373.4060200@web.de> Date: Wed, 08 Sep 2010 19:10:11 +0200 From: Michel Onoff User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.9) Gecko/20100825 Thunderbird/3.1.3 MIME-Version: 1.0 To: dev@hc.apache.org Subject: Re: getting the "entity" of a status 304 response References: <4C86664A.90805@web.de> <1283887432.1846.12.camel@ubuntu> <4C8759AF.2030102@web.de> <1283939400.15185.68.camel@ubuntu> In-Reply-To: <1283939400.15185.68.camel@ubuntu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: michel.onoff@web.de X-Sender: michel.onoff@web.de X-Provags-ID: V01U2FsdGVkX18RBlLmu5Jvr5kN7c2qFiZNmRwjuflOsyBOL0t1 D7TWM9A/nasgyfUOV6FzEu6eH+j3AWfqmmuYljC2o1O1H59smJ eAbL2jrFijj9iJgZhG+Q== On 2010-09-08 11:50, Oleg Kalnichevski wrote: > On Wed, 2010-09-08 at 11:38 +0200, Michel Onoff wrote: >> On 2010-09-07 21:23, Oleg Kalnichevski wrote: >>> On Tue, 2010-09-07 at 18:20 +0200, Michel Onoff wrote: >>>> By specification, HTTP response 304 Not Modified has no entity. >>>> >>>> However, getEntity() on the BasicHttpResponse still returns a non-null >>>> entity. Trying to getContent() and read() then blocks. The same happens >>>> if one tries to send the response with >>>> HttpServerConnection.sendResponseEntity(response). >>>> >>>> Is this supposed to be correct behavior? In other words, must the >>>> programmer be aware of which responses might have an entity? Why can't >>>> he rely on the return value of getEntity()? >>>> >>> >>> Michel, >>> >>> BasicHttpResponse does not have any protocol specific logic. It is >>> merely a bean with properties. It is the responsibility of the protocol >>> processor to assign an instance of HttpEntity to the response object if >>> a response content is expected. >>> >>> I am fairly confident the standard HTTP protocol processors handle 304 >>> Not Modified responses correctly >>> >>> http://hc.apache.org/httpcomponents-core-4.0.1/httpcore/xref/org/apache/http/protocol/HttpRequestExecutor.html#290 >>> http://hc.apache.org/httpcomponents-core-4.0.1/httpcore/xref/org/apache/http/protocol/HttpRequestExecutor.html#83 >>> >>> What is it exactly you are trying to do and what module (HttpCore, >>> HttpCore NIO, HttpClient) are you using? >>> >> >> In fact, I'm using the blocking core directly (http connections, >> requests, responses, entities and headers), without using protocol-aware >> processors. The idea is to have as few overhead as possible, given that >> I'm trying to build a load-balancer which simply forwards requests to >> available servers and responses back to the originating clients in the >> right order. >> >> I'll have a look at the processors and try to experiment with them to >> evaluate if performance still remains reasonable. >> >> Thanks for the explanation >> MO >> > > Michel > > You can certainly continue using your custom protocol handling code, but > you will have to ensure it is capable of dealing with responses that are > not meant to enclose a content body (status 304, responses to HEAD, etc) > I took a look at the processor API. Unfortunately, it doesn't fit in my project. For my usage, I would need a processor for *incoming* responses: alas, there are no ready-to-use class for that. I cannot use HttpRequestExecutor either, because I send a request on a client connection in one thread and receive the response on the same connection in another thread (full-duplex usage in different sending and receiving threads). So, instead of implementing a processor for incoming responses, it's easier for me to check the availability of an entity based on the status code of the response or the type of the originating request. Cheers MO --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org