Example usage for org.apache.http.impl.io ContentLengthInputStream ContentLengthInputStream

List of usage examples for org.apache.http.impl.io ContentLengthInputStream ContentLengthInputStream

Introduction

In this page you can find the example usage for org.apache.http.impl.io ContentLengthInputStream ContentLengthInputStream.

Prototype

public ContentLengthInputStream(SessionInputBuffer sessionInputBuffer, long j) 

Source Link

Usage

From source file:org.apache.axis2.transport.http.server.AxisHttpConnectionImpl.java

public HttpRequest receiveRequest() throws HttpException, IOException {
    HttpRequest request = (HttpRequest) this.requestParser.parse();
    if (HEADERLOG.isDebugEnabled()) {
        HEADERLOG.debug(">> " + request.getRequestLine().toString());
        for (HeaderIterator it = request.headerIterator(); it.hasNext();) {
            HEADERLOG.debug(">> " + it.nextHeader().toString());
        }/*from w  w  w. ja v  a 2s  .co m*/
    }

    // Prepare input stream
    this.in = null;
    if (request instanceof HttpEntityEnclosingRequest) {
        long len = this.contentLenStrategy.determineLength(request);
        if (len == ContentLengthStrategy.CHUNKED) {
            this.in = new ChunkedInputStream(this.inbuffer);
        } else if (len == ContentLengthStrategy.IDENTITY) {
            this.in = new IdentityInputStream(this.inbuffer);
        } else {
            this.in = new ContentLengthInputStream(inbuffer, len);
        }
    }
    return request;
}

From source file:org.mycard.net.network.AndroidHttpClientConnection.java

/***
 * Return the next response entity./*  www .  j  ava  2s.co m*/
 * @param headers contains values for parsing entity
 * @see HttpClientConnection#receiveResponseEntity(HttpResponse response)
 */
public HttpEntity receiveResponseEntity(final Headers headers) {
    assertOpen();
    BasicHttpEntity entity = new BasicHttpEntity();

    long len = determineLength(headers);
    if (len == ContentLengthStrategy.CHUNKED) {
        entity.setChunked(true);
        entity.setContentLength(-1);
        entity.setContent(new ChunkedInputStream(inbuffer));
    } else if (len == ContentLengthStrategy.IDENTITY) {
        entity.setChunked(false);
        entity.setContentLength(-1);
        entity.setContent(new IdentityInputStream(inbuffer));
    } else {
        entity.setChunked(false);
        entity.setContentLength(len);
        entity.setContent(new ContentLengthInputStream(inbuffer, len));
    }

    String contentTypeHeader = headers.getContentType();
    if (contentTypeHeader != null) {
        entity.setContentType(contentTypeHeader);
    }
    String contentEncodingHeader = headers.getContentEncoding();
    if (contentEncodingHeader != null) {
        entity.setContentEncoding(contentEncodingHeader);
    }

    return entity;
}