net.jxta.search.util
Class HttpConnectionService

java.lang.Object
  |
  +--net.jxta.search.util.HttpConnectionService

public class HttpConnectionService
extends java.lang.Object

HttpConnectionService maintains a cache of open connections, so that repeated http client connections to other hosts don't result in needless tcp open/closes. This is possible because the HttpConnection class is good at implementing the necessary HTTP/1.1 semantics like keep-alive and chunking.

(java.net.HttpURLConnection doesn't support chunked encoding, while most server-side page-generation tools use it.); Usage:

 HttpConnectionService service = new HttpConnectionService (null);
 HttpConnection.Request req;
 HttpConnection.Response res;
 InputStream in;

 req =  service.beginRequest (new URL ("http://www.ibm.com/products/"),
                              "GET",
                              5 * 100);
 req.setHeader ("Foo", "bar");

 res = req.getResponse ();

 try {
   in = req.getInputStream ();
  
   // read from the stream 		       
 } finally {
   res.done ();
 }
 


Constructor Summary
HttpConnectionService(java.util.HashMap dontCacheHosts)
           
 
Method Summary
 HttpConnection.Request beginRequest(java.net.URL url, java.lang.String method, int readTimeout)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpConnectionService

public HttpConnectionService(java.util.HashMap dontCacheHosts)
Parameters:
HashMap - table of hosts connections to which should not be cached or null if all connections should be cached.
Method Detail

beginRequest

public HttpConnection.Request beginRequest(java.net.URL url,
                                           java.lang.String method,
                                           int readTimeout)
                                    throws java.io.IOException,
                                           java.lang.InterruptedException