@Override protected void doClose() { channel.close(); } }
private static void writeRequest(AsyncChannelWrapper channel, ByteBuffer request, long timeout) throws TimeoutException, InterruptedException, ExecutionException { int toWrite = request.limit(); Future<Integer> fWrite = channel.write(request); Integer thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); while (toWrite > 0) { fWrite = channel.write(request); thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); } }
fConnect.get(timeout, TimeUnit.MILLISECONDS); Future<Void> fHandshake = channel.handshake(); fHandshake.get(timeout, TimeUnit.MILLISECONDS); Future<Integer> fWrite = channel.write(request); Integer thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); fWrite = channel.write(request); thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); } finally { if (!success) { channel.close();
private void processSocketRead() throws IOException { while (response.hasRemaining()) { int remaining = response.remaining(); int toCopy = Math.min(remaining, inputBuffer.length - writePos); // Copy remaining bytes read in HTTP phase to input buffer used by // frame processing response.get(inputBuffer, writePos, toCopy); writePos += toCopy; // Process the data we have processInputBuffer(); } response.clear(); // Get some more data if (isOpen()) { channel.read(response, null, handler); } }
fConnect.get(timeout, TimeUnit.MILLISECONDS); Future<Void> fHandshake = channel.handshake(); fHandshake.get(timeout, TimeUnit.MILLISECONDS); Future<Integer> fWrite = channel.write(request); Integer thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); fWrite = channel.write(request); thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue();
private void processSocketRead() throws IOException { while (response.hasRemaining()) { int remaining = response.remaining(); int toCopy = Math.min(remaining, inputBuffer.length - writePos); // Copy remaining bytes read in HTTP phase to input buffer used by // frame processing response.get(inputBuffer, writePos, toCopy); writePos += toCopy; // Process the data we have processInputBuffer(); } response.clear(); // Get some more data if (isOpen()) { channel.read(response, null, handler); } }
private void processSocketRead() throws IOException { while (response.hasRemaining()) { int remaining = response.remaining(); int toCopy = Math.min(remaining, inputBuffer.length - writePos); // Copy remaining bytes read in HTTP phase to input buffer used by // frame processing response.get(inputBuffer, writePos, toCopy); writePos += toCopy; // Process the data we have processInputBuffer(); } response.clear(); // Get some more data if (isOpen()) { channel.read(response, null, handler); } }
private static void writeRequest(AsyncChannelWrapper channel, ByteBuffer request, long timeout) throws TimeoutException, InterruptedException, ExecutionException { int toWrite = request.limit(); Future<Integer> fWrite = channel.write(request); Integer thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); while (toWrite > 0) { fWrite = channel.write(request); thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); } }
@Override protected void doClose() { channel.close(); } }
Future<Integer> read = channel.read(response); Integer bytesRead = read.get(timeout, TimeUnit.MILLISECONDS); if (bytesRead.intValue() == -1) {
private static void writeRequest(AsyncChannelWrapper channel, ByteBuffer request, long timeout) throws TimeoutException, InterruptedException, ExecutionException { int toWrite = request.limit(); Future<Integer> fWrite = channel.write(request); Integer thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); while (toWrite > 0) { fWrite = channel.write(request); thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); } }
@Override protected void doClose() { channel.close(); } }
while (!readHeaders) { Future<Integer> read = channel.read(response); Integer bytesRead = read.get(timeout, TimeUnit.MILLISECONDS); if (bytesRead.intValue() == -1) {
@Override protected void doWrite(SendHandler handler, ByteBuffer... data) { long timeout = getSendTimeout(); if (timeout < 1) { timeout = Long.MAX_VALUE; } SendHandlerToCompletionHandler sh2ch = new SendHandlerToCompletionHandler(handler); channel.write(data, 0, data.length, timeout, TimeUnit.MILLISECONDS, null, sh2ch); }
@Override protected void doClose() { channel.close(); } }
channel.read(response, null, handler); } else { changeReadState(ReadState.CLOSING);
@Override protected void doWrite(SendHandler handler, ByteBuffer... data) { long timeout = getSendTimeout(); if (timeout < 1) { timeout = Long.MAX_VALUE; } SendHandlerToCompletionHandler sh2ch = new SendHandlerToCompletionHandler(handler); try { channel.write(data, 0, data.length, timeout, TimeUnit.MILLISECONDS, null, sh2ch); } catch (IllegalStateException ise) { sh2ch.failed(ise, null); } }