< prev index next >

src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java

Print this page




 214             ByteBufferReference.clear(buffers);
 215         } else {
 216             // Unordered frames are sent before existing frames.
 217             asyncOutputQ.putFirst(buffers);
 218         }
 219     }
 220 
 221     @Override
 222     public void flushAsync() throws IOException {
 223         if (getMode() == Mode.ASYNC) {
 224             asyncOutputQ.flush();
 225         }
 226     }
 227 
 228     @Override
 229     public void enableCallback() {
 230         // not used
 231         assert false;
 232     }
 233 
 234     void asyncOutput(ByteBufferReference[] refs, AsyncWriteQueue delayCallback) {
 235         try {
 236             ByteBuffer[] bufs = ByteBufferReference.toBuffers(refs);
 237             while (Utils.remaining(bufs) > 0) {
 238                 long n = chan.write(bufs);
 239                 if (n == 0) {
 240                     delayCallback.setDelayed(refs);
 241                     client.registerEvent(new WriteEvent());
 242                     return;
 243                 }
 244             }
 245             ByteBufferReference.clear(refs);
 246         } catch (IOException e) {
 247             shutdown();
 248         }

 249     }
 250 
 251     @Override
 252     public String toString() {
 253         return "PlainHttpConnection: " + super.toString();
 254     }
 255 
 256     /**
 257      * Close this connection
 258      */
 259     @Override
 260     public synchronized void close() {
 261         if (closed) {
 262             return;
 263         }
 264         closed = true;
 265         try {
 266             Log.logError("Closing: " + toString());
 267             chan.close();
 268         } catch (IOException e) {}




 214             ByteBufferReference.clear(buffers);
 215         } else {
 216             // Unordered frames are sent before existing frames.
 217             asyncOutputQ.putFirst(buffers);
 218         }
 219     }
 220 
 221     @Override
 222     public void flushAsync() throws IOException {
 223         if (getMode() == Mode.ASYNC) {
 224             asyncOutputQ.flush();
 225         }
 226     }
 227 
 228     @Override
 229     public void enableCallback() {
 230         // not used
 231         assert false;
 232     }
 233 
 234     boolean asyncOutput(ByteBufferReference[] refs, AsyncWriteQueue delayCallback) {
 235         try {
 236             ByteBuffer[] bufs = ByteBufferReference.toBuffers(refs);
 237             while (Utils.remaining(bufs) > 0) {
 238                 long n = chan.write(bufs);
 239                 if (n == 0) {
 240                     delayCallback.setDelayed(refs);
 241                     client.registerEvent(new WriteEvent());
 242                     return false;
 243                 }
 244             }
 245             ByteBufferReference.clear(refs);
 246         } catch (IOException e) {
 247             shutdown();
 248         }
 249         return true;
 250     }
 251 
 252     @Override
 253     public String toString() {
 254         return "PlainHttpConnection: " + super.toString();
 255     }
 256 
 257     /**
 258      * Close this connection
 259      */
 260     @Override
 261     public synchronized void close() {
 262         if (closed) {
 263             return;
 264         }
 265         closed = true;
 266         try {
 267             Log.logError("Closing: " + toString());
 268             chan.close();
 269         } catch (IOException e) {}


< prev index next >