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 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();
@Override protected void onContentReceived(ContentDecoder decoder, IOControl ioctrl) throws IOException { SimpleInputBuffer buf = this.buf; if (buf == null) throw new NullPointerException("Content Buffer"); buf.consumeContent(decoder); }
@Override protected void onResponseReceived(HttpResponse response) throws HttpException, IOException { ConnectionResponse clientResponse = new ConnectionResponse(configuration, properties); copyResponse(response, clientResponse); final HttpEntity entity = response.getEntity(); if (entity != null) { long len = entity.getContentLength(); if (len > Integer.MAX_VALUE) { throw new ContentTooLongException("Entity content is too long: " + len); } if (len < 0) { len = 4096; } this.buf = new SimpleInputBuffer((int) len, new HeapByteBufferAllocator()); } this.clientResponse = clientResponse; }
public BufferingHttpServiceHandler( final HttpProcessor httpProcessor, final HttpResponseFactory responseFactory, final ConnectionReuseStrategy connStrategy, final HttpParams params) { this(httpProcessor, responseFactory, connStrategy, new HeapByteBufferAllocator(), params); }
public int read(final byte[] b) throws IOException { if (isEndOfStream()) { return -1; } if (b == null) { return 0; } return read(b, 0, b.length); }
public void write(final byte[] b) throws IOException { if (b == null) { return; } write(b, 0, b.length); }
if (entity != null) sharedStream = new SharedInputStream(new SharedInputBuffer(16 * 1024));
public void write(final byte[] b) throws IOException { if (b == null) { return; } if (this.endOfStream) { return; } write(b, 0, b.length); }
@Override public void reset() { this.endOfStream = false; super.clear(); }
@Override public int read(final byte[] b) throws IOException { if (b == null) { return 0; } return this.buffer.read(b, 0, b.length); }
public int read(final byte[] b) throws IOException { if (this.shutdown) { return -1; } if (b == null) { return 0; } return read(b, 0, b.length); }
@Override public void write(final byte[] b) throws IOException { if (b == null) { return; } this.buffer.write(b, 0, b.length); }
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 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();
public int read(final byte[] b) throws IOException { if (isEndOfStream()) { return -1; } if (b == null) { return 0; } return read(b, 0, b.length); }
public void write(final byte[] b) throws IOException { if (b == null) { return; } if (this.endOfStream) { return; } write(b, 0, b.length); }
@Override public void reset() { super.clear(); this.endOfStream = false; }
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); }