Example usage for org.apache.http.nio ContentDecoder read

List of usage examples for org.apache.http.nio ContentDecoder read

Introduction

In this page you can find the example usage for org.apache.http.nio ContentDecoder read.

Prototype

int read(ByteBuffer dst) throws IOException;

Source Link

Document

Reads a portion of content from the underlying channel

Usage

From source file:org.apache.http.impl.nio.client.DefaultAsyncRequestDirector.java

@Override
public synchronized void consumeContent(final ContentDecoder decoder, final IOControl ioctrl)
        throws IOException {
    if (this.log.isDebugEnabled()) {
        this.log.debug("[exchange: " + this.id + "] Consume content");
    }/*from   w w  w.jav a2s  .c  om*/
    if (this.finalResponse != null) {
        this.responseConsumer.consumeContent(decoder, ioctrl);
    } else {
        if (this.tmpbuf == null) {
            this.tmpbuf = ByteBuffer.allocate(2048);
        }
        this.tmpbuf.clear();
        decoder.read(this.tmpbuf);
    }
}

From source file:org.apache.http.impl.nio.client.MainClientExec.java

@Override
public void consumeContent(final InternalState state, final ContentDecoder decoder, final IOControl ioctrl)
        throws IOException {
    if (this.log.isDebugEnabled()) {
        this.log.debug("[exchange: " + state.getId() + "] Consume content");
    }/*from www .  j a va  2s  .c o m*/
    if (state.getFinalResponse() != null) {
        final HttpAsyncResponseConsumer<?> responseConsumer = state.getResponseConsumer();
        responseConsumer.consumeContent(decoder, ioctrl);
    } else {
        final ByteBuffer tmpbuf = state.getTmpbuf();
        tmpbuf.clear();
        decoder.read(tmpbuf);
    }
}