Hi John, I was asking for what seems to be already in HttpURLConnection, a way to reuse the HTTP connection without having to manually reuse the same object instance. Sean probably thought that the HTTP connections were not reused because he was not fully reading the responses... What I learned is that JDK 6 seems to improve the reuse by collecting more aggressively unread connections.
Now, we agree that the HttpURLConnection design is dated, but it is good to see it improved as much as possible. Relying on Apache HTTP Client is a good alternative, especially if they add support for NIO. At some point it will be probably be just better to directly implement the connector ourselves in order to have full control on the socket, NIO, reuse, etc. Best regards, Jerome > -----Message d'origine----- > De : John D. Mitchell [mailto:[EMAIL PROTECTED] > Envoyé : mardi 28 novembre 2006 00:55 > À : [email protected] > Objet : Re: Re: Keeping a client connection open > > I'm not sure what you're asking for. Adding support for Apache's > HTTPClient is, for me, a good thing for the future when they finally > support NIO-based use. > > The standard JDK's HttpURLConnection has always been a wacky approach > and then they add more wackiness underneath it to try and make up for > the bad original design. For example, all of the conditions that must > be met before the connection is "transparently" reused. > > Thanks, > John > > On 11/27/06, Jerome Louvel <[EMAIL PROTECTED]> wrote: > > The bug report was posted on Sun's site > > > (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6495923) > and has the > > following evaluation comment: > > > > "The description is not accurate. HttpURLConnection does support > > persistent connections. By default it maintains an internal cache of > > connections, allowing it to reuse the same connection for multiple > > requests to the same host/proxy. There is no requirement for the > > HttpURLConnection instance to be the same. The cache is > static and is > > across all HttpURLConnections. > > > > To take advantage of this feature couldn't be easier, > simply read the > > data off the InputStream and close it when finished. It is the close > > action that will try to put the actual underlying > connection into the > > "keep alive" cache. > > > > see: > > http://java.sun.com/j2se/1.5.0/docs/guide/net/http-keepalive.html > > http://blogs.sun.com/chegar/entry/http_keep_alive_improvements > > " > > > > Any thought? > > > > Best, > > Jerome > > > > > > Jerome Louvel : > > > Hi John, > > > > > > I've reported the issue with connection reuse in JDK's > HttpUrlConnection > > > class and suggested that they add a transparent reuse > mechanism similar > > > to Apache HTTP Client. > > > > > > The bug report was accepted and will show at this URL in > a couple of > > > days: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6495923 > > > > > > Best regards, > > > Jerome > >

