net.jxta.search.util
Class HttpConnection

java.lang.Object
  |
  +--net.jxta.search.util.HttpConnection
All Implemented Interfaces:
net.jxta.search.util.LRUCache.Cacheable

public class HttpConnection
extends java.lang.Object
implements net.jxta.search.util.LRUCache.Cacheable

HTTP 1.1 support: keep-alive and chunked transfer-encoding.

Below is a usage example. However, you are best off using the api of HttpConnectionService

 HttpConnectionService service = new HttpConnectionService ();
 HttpConnection        con     = new HttpConnection (new URL ("http://www.ibm.com/"), 
                                                     5 * 1000,
                                                     service);
 
 HttpConnection.Request  req = con.beginRequest (new URL ("http://www.ibm.com/products/index.html"), "GET");
 HttpConnection.Response res;
 InputStream             in;
 
 req.setHeadder ("Foo", "bar");
 
 res = req.getResponse ();
 
 try {
     in = res.getInputStream ();
 
   // read from the stream
 } finally {
     res.done ();
 }
 
 


Inner Class Summary
 class HttpConnection.Request
           
 class HttpConnection.Response
           
 
Constructor Summary
HttpConnection(java.net.URL url, int readTimeout, HttpConnectionService service)
           
 
Method Summary
 HttpConnection.Request beginRequest(java.net.URL url, java.lang.String method)
           
 void deleted()
          LRUCache.Cacheable implementation - this method is called when the object is deleted from the cache.
 void disconnect()
           
 int getCost()
          Get the cost of establishing the connection to this host.
 java.net.URL getHostURL()
           
 int getWaitingRequestorCount()
           
 boolean isInRequest()
           
static void main(java.lang.String[] argv)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpConnection

public HttpConnection(java.net.URL url,
                      int readTimeout,
                      HttpConnectionService service)
Method Detail

getHostURL

public java.net.URL getHostURL()

getCost

public int getCost()
Get the cost of establishing the connection to this host.
Specified by:
getCost in interface net.jxta.search.util.LRUCache.Cacheable

deleted

public void deleted()
LRUCache.Cacheable implementation - this method is called when the object is deleted from the cache.
Specified by:
deleted in interface net.jxta.search.util.LRUCache.Cacheable

disconnect

public void disconnect()

isInRequest

public boolean isInRequest()

getWaitingRequestorCount

public int getWaitingRequestorCount()

beginRequest

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

main

public static void main(java.lang.String[] argv)
                 throws java.io.IOException,
                        java.lang.InterruptedException