public void contentAvailable(ContentDecoder decoder, IOControl ioctrl) throws IOException { long transferred; if (useFileChannels && decoder instanceof FileContentDecoder) { transferred = ((FileContentDecoder) decoder).transfer(fileChannel, idx, Long.MAX_VALUE); } else { transferred = fileChannel.transferFrom(new ContentDecoderChannel(decoder), idx, Long.MAX_VALUE); } if (transferred > 0) idx += transferred; }
public void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException { if (out == null) { synchronized (mutex) { out = new SharedOutputBuffer(8192, ioctrl, new HeapByteBufferAllocator()); mutex.notify(); } } while (!encoder.isCompleted()) out.produceContent(encoder); }
@Override public void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException { encoder.complete(); if (shouldCheckProxyAuth() && requestHasBeenReset) { logger.debug("Produced content again, assuming the proxy server requires authentication."); proxyAuthRequiresResend.set(true); } }
private void writeBuffer(ContentEncoder encoder) throws IOException { while (buffer.hasRemaining()) { final int written = encoder.write(buffer); logger.trace("written {} bytes to encoder.", written); if (written == 0) { logger.trace("Buffer still has remaining. {}", buffer); bufferHasRemainingData.set(true); return; } totalProduced += written; } bufferHasRemainingData.set(false); buffer.clear(); }
public void connectionOpen(final NHttpConnection conn) { logger.info("Connection from " + conn.getContext().getAttribute(ExecutionContext.HTTP_TARGET_HOST) // conn.getInetAddress().getHostName() ); }
@Override public void resetOutput() { this.response = null; this.contentEncoder = null; this.responseWriter.reset(); }
@Override public void resetInput() { this.request = null; this.contentDecoder = null; this.requestParser.reset(); }
@Override public void requestReady( final NHttpClientConnection conn) throws IOException, HttpException { this.handler.requestReady(conn); }
@Override public void outputReady( final NHttpClientConnection conn, final ContentEncoder encoder) throws IOException, HttpException { this.handler.outputReady(conn, encoder); }
@Override public void responseReady( final NHttpServerConnection conn) throws IOException, HttpException { this.handler.responseReady(conn); }
@Override public void inputReady( final NHttpServerConnection conn, final ContentDecoder decoder) throws IOException, HttpException { this.handler.inputReady(conn, decoder); }
@Override public void outputReady( final NHttpServerConnection conn, final ContentEncoder encoder) throws IOException, HttpException { this.handler.outputReady(conn, encoder); }
public void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException { if (out == null) { synchronized (mutex) { out = new SharedOutputBuffer(8192, ioctrl, new HeapByteBufferAllocator()); mutex.notify(); } } while (!encoder.isCompleted()) out.produceContent(encoder); }
public void contentAvailable(ContentDecoder decoder, IOControl ioctrl) throws IOException { long transferred; if (useFileChannels && decoder instanceof FileContentDecoder) { transferred = ((FileContentDecoder) decoder).transfer(fileChannel, idx, Long.MAX_VALUE); } else { transferred = fileChannel.transferFrom(new ContentDecoderChannel(decoder), idx, Long.MAX_VALUE); } if (transferred > 0) idx += transferred; }
public void connectionOpen(final NHttpConnection conn) { logger.info("Connection from " + conn.getContext().getAttribute(ExecutionContext.HTTP_TARGET_HOST) // conn.getInetAddress().getHostName() ); }
@Override public void resetOutput() { this.request = null; this.contentEncoder = null; this.requestWriter.reset(); }
public void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException { final SharedOutputBuffer ob = new SharedOutputBuffer(8192, ioctrl, new HeapByteBufferAllocator()); new Thread() { public void run() { try { FileInputStream fis = new FileInputStream("/Users/marc/Music/enjoytheride_feat.judytzuke_.mp3"); int nRead; byte[] bytes = new byte[4096]; while ((nRead = fis.read(bytes)) != -1) { synchronized (this) { try { wait(1); } catch (InterruptedException ie) { } } ob.write(bytes, 0, nRead); } ob.writeCompleted(); } catch (IOException e) { e.printStackTrace(); } } }.start(); while (!encoder.isCompleted()) ob.produceContent(encoder); }
public void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException { final SharedOutputBuffer ob = new SharedOutputBuffer(8192, ioctrl, new HeapByteBufferAllocator()); new Thread() { public void run() { try { FileInputStream fis = new FileInputStream("/Users/marc/Music/enjoytheride_feat.judytzuke_.mp3"); int nRead; byte[] bytes = new byte[4096]; while ((nRead = fis.read(bytes)) != -1) { synchronized (this) { try { wait(1); } catch (InterruptedException ie) { } } ob.write(bytes, 0, nRead); } ob.writeCompleted(); } catch (IOException e) { e.printStackTrace(); } } }.start(); while (!encoder.isCompleted()) ob.produceContent(encoder); }