/** * Read / Parse the waiting read/fill buffer * * @param buffer the buffer to fill into from the endpoint * @return true if there is more to read, false if reading should stop */ private boolean read(ByteBuffer buffer) { EndPoint endPoint = getEndPoint(); try { while (true) { int filled = endPoint.fill(buffer); if (filled == 0) { return true; } else if (filled < 0) { LOG.debug("read - EOF Reached"); return false; } else { if (LOG.isDebugEnabled()) { LOG.debug("Filled {} bytes - {}", filled, BufferUtil.toDetailString(buffer)); } ClientUpgradeResponse resp = parser.parse(buffer); if (resp != null) { // Got a response! client.setUpgradeResponse(resp); validateResponse(resp); notifyConnect(resp); upgradeConnection(resp); return false; // do no more reading } } } } catch (IOException e) { LOG.warn(e); client.failed(e); disconnect(false); return false; } catch (UpgradeException e) { LOG.warn(e); client.failed(e); disconnect(false); return false; } }