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

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

Introduction

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

Prototype

public ContentLengthOutputStream(SessionOutputBuffer sessionOutputBuffer, long j) 

Source Link

Usage

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

public void sendResponse(final HttpResponse response) throws HttpException, IOException {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }//ww w. j av a2s .c  o m

    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();
    }
}