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

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

Introduction

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

Prototype

public IdentityOutputStream(SessionOutputBuffer sessionOutputBuffer) 

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");
    }//from www.  j a va  2 s. 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();
    }
}