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

项目:FoDBugTrackerUtility    文件:ApacheConnector.java   
@Override
protected OutputStream createOutputStream(final long len, final SessionOutputBuffer outbuffer) {
    if (len == ContentLengthStrategy.CHUNKED) {
        return new ChunkedOutputStream(chunkSize, outbuffer);
    }
    return super.createOutputStream(len, outbuffer);
}
项目:wso2-axis2    文件:AxisHttpConnectionImpl.java   
public void sendResponse(final HttpResponse response) 
        throws HttpException, IOException {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }

    if (HEADERLOG.isDebugEnabled()) {
        HEADERLOG.debug("<< " + response.getStatusLine().toString());
        for (HeaderIterator it = response.headerIterator(); it.hasNext(); ) {
            HEADERLOG.debug("<< " + it.nextHeader().toString());
        }
    }

    this.responseWriter.write(response);

    // Prepare output stream
    this.out = null;
    ProtocolVersion ver = response.getStatusLine().getProtocolVersion();
    HttpEntity entity = response.getEntity();
    if (entity != null) {
        long len = entity.getContentLength();
        if (entity.isChunked() && ver.greaterEquals(HttpVersion.HTTP_1_1)) {
            this.out = new ChunkedOutputStream(this.outbuffer);
        } else if (len >= 0) {
            this.out = new ContentLengthOutputStream(this.outbuffer, len);
        } else {
            this.out = new IdentityOutputStream(this.outbuffer); 
        }
    } else {
        this.outbuffer.flush();
    }
}
项目:lams    文件:EntitySerializer.java   
/**
 * Creates a transfer codec based on properties of the given HTTP message
 * and returns {@link OutputStream} instance that transparently encodes
 * output data as it is being written out to the output stream.
 * <p>
 * This method is called by the public
 * {@link #serialize(SessionOutputBuffer, HttpMessage, HttpEntity)}.
 *
 * @param outbuffer the session output buffer.
 * @param message the HTTP message.
 * @return output stream.
 * @throws HttpException in case of HTTP protocol violation.
 * @throws IOException in case of an I/O error.
 */
protected OutputStream doSerialize(
        final SessionOutputBuffer outbuffer,
        final HttpMessage message) throws HttpException, IOException {
    long len = this.lenStrategy.determineLength(message);
    if (len == ContentLengthStrategy.CHUNKED) {
        return new ChunkedOutputStream(outbuffer);
    } else if (len == ContentLengthStrategy.IDENTITY) {
        return new IdentityOutputStream(outbuffer);
    } else {
        return new ContentLengthOutputStream(outbuffer, len);
    }
}