Java 类org.apache.http.impl.io.IdentityInputStream 实例源码

项目:wso2-axis2    文件: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());
        }
    }

    // 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;
}
项目:lams    文件:EntityDeserializer.java   
/**
 * Creates a {@link BasicHttpEntity} based on properties of the given
 * message. The content of the entity is created by wrapping
 * {@link SessionInputBuffer} with a content decoder depending on the
 * transfer mechanism used by the message.
 * <p>
 * This method is called by the public
 * {@link #deserialize(SessionInputBuffer, HttpMessage)}.
 *
 * @param inbuffer the session input buffer.
 * @param message the message.
 * @return HTTP entity.
 * @throws HttpException in case of HTTP protocol violation.
 * @throws IOException in case of an I/O error.
 */
protected BasicHttpEntity doDeserialize(
        final SessionInputBuffer inbuffer,
        final HttpMessage message) throws HttpException, IOException {
    BasicHttpEntity entity = new BasicHttpEntity();

    long len = this.lenStrategy.determineLength(message);
    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));
    }

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