< prev index next >

src/java.httpclient/share/classes/java/net/http/HttpConnection.java

Print this page
rev 15335 : Async Queues


  36 /**
  37  * Wraps socket channel layer and takes care of SSL also.
  38  *
  39  * Subtypes are:
  40  *      PlainHttpConnection: regular direct TCP connection to server
  41  *      PlainProxyConnection: plain text proxy connection
  42  *      PlainTunnelingConnection: opens plain text (CONNECT) tunnel to server
  43  *      SSLConnection: TLS channel direct to server
  44  *      SSLTunnelConnection: TLS channel via (CONNECT) proxy tunnel
  45  */
  46 abstract class HttpConnection implements BufferHandler, Closeable {
  47 
  48     protected final static ByteBuffer emptyBuf = Utils.EMPTY_BYTEBUFFER;
  49 
  50     enum Mode {
  51         BLOCKING,
  52         NON_BLOCKING,
  53         ASYNC
  54     }
  55 
  56     protected Mode mode;


  57 
  58     // address we are connected to. Could be a server or a proxy
  59     final InetSocketAddress address;
  60     final HttpClientImpl client;
  61     protected volatile ByteBuffer buffer;
  62 
  63     HttpConnection(InetSocketAddress address, HttpClientImpl client) {
  64         this.address = address;
  65         this.client = client;
  66         this.buffer = emptyBuf;
  67     }
  68 
  69     /**
  70      * Public API to this class. addr is the ultimate destination. Any proxies
  71      * etc are figured out from the request. Returns an instance of one of the
  72      * following
  73      *      PlainHttpConnection
  74      *      PlainTunnelingConnection
  75      *      SSLConnection
  76      *      SSLTunnelConnection




  36 /**
  37  * Wraps socket channel layer and takes care of SSL also.
  38  *
  39  * Subtypes are:
  40  *      PlainHttpConnection: regular direct TCP connection to server
  41  *      PlainProxyConnection: plain text proxy connection
  42  *      PlainTunnelingConnection: opens plain text (CONNECT) tunnel to server
  43  *      SSLConnection: TLS channel direct to server
  44  *      SSLTunnelConnection: TLS channel via (CONNECT) proxy tunnel
  45  */
  46 abstract class HttpConnection implements BufferHandler, Closeable {
  47 
  48     protected final static ByteBuffer emptyBuf = Utils.EMPTY_BYTEBUFFER;
  49 
  50     enum Mode {
  51         BLOCKING,
  52         NON_BLOCKING,
  53         ASYNC
  54     }
  55 
  56     // mode should be volatile, because of reading of the field is not protected by any synchronization
  57     protected volatile Mode mode;
  58 
  59 
  60     // address we are connected to. Could be a server or a proxy
  61     final InetSocketAddress address;
  62     final HttpClientImpl client;
  63     protected volatile ByteBuffer buffer;
  64 
  65     HttpConnection(InetSocketAddress address, HttpClientImpl client) {
  66         this.address = address;
  67         this.client = client;
  68         this.buffer = emptyBuf;
  69     }
  70 
  71     /**
  72      * Public API to this class. addr is the ultimate destination. Any proxies
  73      * etc are figured out from the request. Returns an instance of one of the
  74      * following
  75      *      PlainHttpConnection
  76      *      PlainTunnelingConnection
  77      *      SSLConnection
  78      *      SSLTunnelConnection


< prev index next >