@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; }
@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); }
public boolean isEndOfStream() { return !hasData() && this.endOfStream; }
public int read(final byte[] b) throws IOException { if (isEndOfStream()) { return -1; } if (b == null) { return 0; } return read(b, 0, b.length); }
@Override public int read() throws IOException { if (isEndOfStream()) { return -1; } setOutputMode(); return this.buffer.get() & 0xff; }
@Override public int consumeContent(final ContentDecoder decoder) throws IOException { setInputMode(); int totalRead = 0; int bytesRead; while ((bytesRead = decoder.read(this.buffer)) != -1) { if (bytesRead == 0) { if (!this.buffer.hasRemaining()) { expand(); } else { break; } } else { totalRead += bytesRead; } } if (bytesRead == -1 || decoder.isCompleted()) { this.endOfStream = true; } return totalRead; }
@Override public int read() throws IOException { if (isEndOfStream()) { return -1; } setOutputMode(); return this.buffer.get() & 0xff; }
public int read(final byte[] b) throws IOException { if (isEndOfStream()) { return -1; } if (b == null) { return 0; } return read(b, 0, b.length); }
@Override public int consumeContent(final ContentDecoder decoder) throws IOException { setInputMode(); int totalRead = 0; int bytesRead; while ((bytesRead = decoder.read(this.buffer)) != -1) { if (bytesRead == 0) { if (!this.buffer.hasRemaining()) { expand(); } else { break; } } else { totalRead += bytesRead; } } if (bytesRead == -1 || decoder.isCompleted()) { this.endOfStream = true; } return totalRead; }
public ContentInputBuffer getInbuffer() { if (this.inbuffer == null) { this.inbuffer = new SimpleInputBuffer(2048, allocator); } return this.inbuffer; }
@Override protected void onContentReceived(ContentDecoder decoder, IOControl ioctrl) throws IOException { this.buf.consumeContent(decoder); }
@Override public int read(final byte[] b, final int off, final int len) throws IOException { if (isEndOfStream()) { return -1; } if (b == null) { return 0; } setOutputMode(); int chunk = len; if (chunk > this.buffer.remaining()) { chunk = this.buffer.remaining(); } this.buffer.get(b, off, chunk); return chunk; }
public boolean isEndOfStream() { return !hasData() && this.endOfStream; }
@Override protected void onEntityEnclosed(HttpEntity entity, ContentType contentType) throws IOException { long len = entity.getContentLength(); if (len > bufferLimitBytes) { throw new ContentTooLongException("entity content is too long [" + len + "] for the configured buffer limit [" + bufferLimitBytes + "]"); } if (len < 0) { len = 4096; } this.buf = new SimpleInputBuffer((int) len, getByteBufferAllocator()); this.response.setEntity(new ContentBufferEntity(entity, this.buf)); }
@Override protected void onContentReceived(ContentDecoder decoder, IOControl ioctrl) throws IOException { this.buf.consumeContent(decoder); }
@Override public int read(final byte[] b, final int off, final int len) throws IOException { if (isEndOfStream()) { return -1; } if (b == null) { return 0; } setOutputMode(); int chunk = len; if (chunk > this.buffer.remaining()) { chunk = this.buffer.remaining(); } this.buffer.get(b, off, chunk); return chunk; }
@Override protected void onEntityEnclosed(HttpEntity entity, ContentType contentType) throws IOException { long len = entity.getContentLength(); if (len > bufferLimitBytes) { throw new ContentTooLongException("entity content is too long [" + len + "] for the configured buffer limit [" + bufferLimitBytes + "]"); } if (len < 0) { len = 4096; } this.buf = new SimpleInputBuffer((int) len, getByteBufferAllocator()); this.response.setEntity(new ContentBufferEntity(entity, this.buf)); }
@Override protected void onContentReceived(ContentDecoder decoder, IOControl ioctrl) throws IOException { this.buf.consumeContent(decoder); }
@Override protected void onEntityEnclosed(HttpEntity entity, ContentType contentType) throws IOException { long len = entity.getContentLength(); if (len > bufferLimitBytes) { throw new ContentTooLongException("entity content is too long [" + len + "] for the configured buffer limit [" + bufferLimitBytes + "]"); } if (len < 0) { len = 4096; } this.buf = new SimpleInputBuffer((int) len, getByteBufferAllocator()); this.response.setEntity(new ContentBufferEntity(entity, this.buf)); }
@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); }