Return-Path: Delivered-To: apmail-jakarta-httpclient-user-archive@www.apache.org Received: (qmail 11123 invoked from network); 30 Aug 2006 20:45:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Aug 2006 20:45:29 -0000 Received: (qmail 69180 invoked by uid 500); 30 Aug 2006 20:45:28 -0000 Delivered-To: apmail-jakarta-httpclient-user-archive@jakarta.apache.org Received: (qmail 69170 invoked by uid 500); 30 Aug 2006 20:45:28 -0000 Mailing-List: contact httpclient-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: "HttpClient User Discussion" Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-user@jakarta.apache.org Received: (qmail 69159 invoked by uid 99); 30 Aug 2006 20:45:28 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2006 13:45:28 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of dlochart@gmail.com designates 64.233.182.184 as permitted sender) Received: from [64.233.182.184] (HELO nf-out-0910.google.com) (64.233.182.184) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2006 13:45:27 -0700 Received: by nf-out-0910.google.com with SMTP id g2so249399nfe for ; Wed, 30 Aug 2006 13:45:06 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=P7khVSfp3ZHXH/TkLzGpB0Wl3JgNHXQ2eLJddP8uovKox171i/q7gbjc3mIN0pPQkYGwYEqHZvZ1yEvk6IBSnOIMK6v55FiAVUpwhJ/KKLLElGqpNSLi+woEXTbetEUUa5zdR0LQDHDNkd1SXMqR1GogftDMBbAWfsFuEYCFlZs= Received: by 10.49.8.1 with SMTP id l1mr241983nfi; Wed, 30 Aug 2006 13:45:05 -0700 (PDT) Received: by 10.49.92.5 with HTTP; Wed, 30 Aug 2006 13:45:05 -0700 (PDT) Message-ID: <1e71f8880608301345vab73d95w5c68a85191b8e76e@mail.gmail.com> Date: Wed, 30 Aug 2006 20:45:05 +0000 From: "Doug Lochart" To: "HttpClient User Discussion" Subject: Re: Persistent connections ? In-Reply-To: <1156965111.4947.52.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_42783_10329556.1156970705687" References: <1e71f8880608301107w605d4d9i4b382ed326a21b64@mail.gmail.com> <1156965111.4947.52.camel@localhost.localdomain> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_42783_10329556.1156970705687 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/30/06, Oleg Kalnichevski wrote: > > > Actually as per RFC2616 Firefox always opens two connections with the > target host if there's more than one entity to be retrieved. So if there are say 7 entities then Firefox would use both connections to get all 7? Or should I expect to see more connections? > To my knowlege I am not explicitly closing the > > connection as I am expecting more connections to come. > > You should be using DefaultConnectionReuseStrategy to determine if a > connection should be kept alive or not. There are cases when HTTP agents > may explicitly request the connection to be closed. I am using DefaultConnectionReuseStrategy in both places. (proxy -> webserver) When I receive the response from the web server and then again (proxy -> client) when the response is serialized. The HttpService I extended does it for me for the (proxy -> client) clase. > > If you look at the > > ElementalHttpServer code you will see pretty much exactly what I am > doing > > when dealing with the client. Eventually the ConnectionProcessorThread > will > > try to read from the socket again as the connections was kept open and I > > will get a Socket Read error. > > > > You are talking about a socket connected to the client host (incoming > connection) or to the target host (outgoing connection)? Here is the code snippet (its connection between the client and the proxy) I realize this is just example code and that may be my current problem but my question is still valid as In this case I expect the connection to be reused and I do not believe that handleRequest() will do a blocking read (thus my timeout error) any suggestions? static class ConnectionProcessorThread extends Thread { private final HttpService httpservice; public ConnectionProcessorThread(final HttpService httpservice) { super(); this.httpservice = httpservice; } public void run() { _logger.debug("New connection thread"); try { while (!Thread.interrupted() && !this.httpservice.isDestroyed() && this.httpservice.isActive()) { _logger.debug("handleRequest() begin"); this.httpservice.handleRequest(); _logger.debug("handleRequest() end"); } } finally { _logger.debug("calling httpservice destroy()"); this.httpservice.destroy(); } _logger.debug("connection thread exiting"); } } In this case what should I do if my ResponseConnControl adds a connection header to keep this connection alive? > > > 3) Is it because its a proxy server and the browsers make new > connections > > to proxies vs reuse existing connections to web servers? > > > > Are you implementing a transparent (reverse) proxy or a standard > (caching) proxy? Did you actually have to tell the browser to connect > via the proxy of yours or not? Actually it is a content stream filtering proxy that will probably sit in front of squid cache when I am done. I am doing content filtering, tag stripping etc as well as providing a flexible template design for specifying classes of urls and being able to apply different rules to those classes. We were using the Sun Proxy Server which claims to do all of this but after I discovered and reported 3 bugs (2 of which were show stoppers and proved the code is hardly tested) we decided to write our own and grow it over time. I do see a ResponseConnControl which answers my other question. Now is there a little write up or anything that discusses the various interceptors or at least describes what is required and what is not and if any ordering of them is required? Any design cheat sheets as it were? thanks Doug --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org > > -- What profits a man if he gains the whole world yet loses his soul? ------=_Part_42783_10329556.1156970705687--