< prev index next >

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

Print this page




 327             HandshakeStatus hs_status = r.result.getHandshakeStatus();
 328             if (hs_status != HandshakeStatus.FINISHED &&
 329                 hs_status != HandshakeStatus.NOT_HANDSHAKING)
 330             {
 331                 doHandshake(hs_status);
 332             }
 333         }
 334         return r;
 335     }
 336 
 337     /**
 338      * read data thru the engine into the given ByteBuffer. If the
 339      * given buffer was not large enough, a new one is allocated
 340      * and returned. This call handles handshaking automatically.
 341      * Caller should check if engine has been closed.
 342      */
 343     WrapperResult recvData (ByteBuffer dst) throws IOException {
 344         /* we wait until some user data arrives */
 345         int mark = dst.position();
 346         WrapperResult r = null;
 347         assert dst.position() == 0;
 348         while (dst.position() == 0) {
 349             r = wrapper.recvAndUnwrap (dst);
 350             dst = (r.buf != dst) ? r.buf: dst;
 351             Status status = r.result.getStatus();
 352             if (status == Status.CLOSED) {
 353                 doClosure ();
 354                 return r;
 355             }
 356 
 357             HandshakeStatus hs_status = r.result.getHandshakeStatus();
 358             if (hs_status != HandshakeStatus.FINISHED &&
 359                 hs_status != HandshakeStatus.NOT_HANDSHAKING)
 360             {
 361                 doHandshake (hs_status);
 362             }
 363         }
 364         Utils.flipToMark(dst, mark);
 365         return r;
 366     }
 367 
 368     /* we've received a close notify. Need to call wrap to send




 327             HandshakeStatus hs_status = r.result.getHandshakeStatus();
 328             if (hs_status != HandshakeStatus.FINISHED &&
 329                 hs_status != HandshakeStatus.NOT_HANDSHAKING)
 330             {
 331                 doHandshake(hs_status);
 332             }
 333         }
 334         return r;
 335     }
 336 
 337     /**
 338      * read data thru the engine into the given ByteBuffer. If the
 339      * given buffer was not large enough, a new one is allocated
 340      * and returned. This call handles handshaking automatically.
 341      * Caller should check if engine has been closed.
 342      */
 343     WrapperResult recvData (ByteBuffer dst) throws IOException {
 344         /* we wait until some user data arrives */
 345         int mark = dst.position();
 346         WrapperResult r = null;
 347         int pos = dst.position();
 348         while (dst.position() == pos) {
 349             r = wrapper.recvAndUnwrap (dst);
 350             dst = (r.buf != dst) ? r.buf: dst;
 351             Status status = r.result.getStatus();
 352             if (status == Status.CLOSED) {
 353                 doClosure ();
 354                 return r;
 355             }
 356 
 357             HandshakeStatus hs_status = r.result.getHandshakeStatus();
 358             if (hs_status != HandshakeStatus.FINISHED &&
 359                 hs_status != HandshakeStatus.NOT_HANDSHAKING)
 360             {
 361                 doHandshake (hs_status);
 362             }
 363         }
 364         Utils.flipToMark(dst, mark);
 365         return r;
 366     }
 367 
 368     /* we've received a close notify. Need to call wrap to send


< prev index next >