Java 类org.apache.http.entity.BasicHttpEntityHC4 实例源码

项目:remote-files-sync    文件:BHttpConnectionBase.java   
protected HttpEntity prepareInput(final HttpMessage message) throws HttpException {
    final BasicHttpEntityHC4 entity = new BasicHttpEntityHC4();

    final long len = this.incomingContentStrategy.determineLength(message);
    final InputStream instream = createInputStream(len, this.inbuffer);
    if (len == ContentLengthStrategy.CHUNKED) {
        entity.setChunked(true);
        entity.setContentLength(-1);
        entity.setContent(instream);
    } else if (len == ContentLengthStrategy.IDENTITY) {
        entity.setChunked(false);
        entity.setContentLength(-1);
        entity.setContent(instream);
    } else {
        entity.setChunked(false);
        entity.setContentLength(len);
        entity.setContent(instream);
    }

    final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
    if (contentTypeHeader != null) {
        entity.setContentType(contentTypeHeader);
    }
    final Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
    if (contentEncodingHeader != null) {
        entity.setContentEncoding(contentEncodingHeader);
    }
    return entity;
}
项目:Visit    文件:BHttpConnectionBase.java   
protected HttpEntity prepareInput(final HttpMessage message) throws HttpException {
    final BasicHttpEntityHC4 entity = new BasicHttpEntityHC4();

    final long len = this.incomingContentStrategy.determineLength(message);
    final InputStream instream = createInputStream(len, this.inbuffer);
    if (len == ContentLengthStrategy.CHUNKED) {
        entity.setChunked(true);
        entity.setContentLength(-1);
        entity.setContent(instream);
    } else if (len == ContentLengthStrategy.IDENTITY) {
        entity.setChunked(false);
        entity.setContentLength(-1);
        entity.setContent(instream);
    } else {
        entity.setChunked(false);
        entity.setContentLength(len);
        entity.setContent(instream);
    }

    final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
    if (contentTypeHeader != null) {
        entity.setContentType(contentTypeHeader);
    }
    final Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
    if (contentEncodingHeader != null) {
        entity.setContentEncoding(contentEncodingHeader);
    }
    return entity;
}
项目:ZTLib    文件:BHttpConnectionBase.java   
protected HttpEntity prepareInput(final HttpMessage message) throws HttpException {
    final BasicHttpEntityHC4 entity = new BasicHttpEntityHC4();

    final long len = this.incomingContentStrategy.determineLength(message);
    final InputStream instream = createInputStream(len, this.inbuffer);
    if (len == ContentLengthStrategy.CHUNKED) {
        entity.setChunked(true);
        entity.setContentLength(-1);
        entity.setContent(instream);
    } else if (len == ContentLengthStrategy.IDENTITY) {
        entity.setChunked(false);
        entity.setContentLength(-1);
        entity.setContent(instream);
    } else {
        entity.setChunked(false);
        entity.setContentLength(len);
        entity.setContent(instream);
    }

    final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
    if (contentTypeHeader != null) {
        entity.setContentType(contentTypeHeader);
    }
    final Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
    if (contentEncodingHeader != null) {
        entity.setContentEncoding(contentEncodingHeader);
    }
    return entity;
}