Package org.apache.http.io

Examples of org.apache.http.io.HttpDataInputStream


            // The chunked encoding must be the last one applied RFC2616, 14.41
            int len = encodings.length;
            if (HTTP.IDENTITY_CODING.equalsIgnoreCase(transferEncodingHeader.getValue())) {
                entity.setChunked(false);
                entity.setContentLength(-1);
                entity.setContent(new HttpDataInputStream(datareceiver));                           
            } else if ((len > 0) && (HTTP.CHUNK_CODING.equalsIgnoreCase(
                    encodings[len - 1].getName()))) {
                entity.setChunked(true);
                entity.setContentLength(-1);
                entity.setContent(new ChunkedInputStream(datareceiver));
            } else {
                if (strict) {
                    throw new ProtocolException("Chunk-encoding must be the last one applied");
                }
                entity.setChunked(false);
                entity.setContentLength(-1);
                entity.setContent(new HttpDataInputStream(datareceiver));                           
            }
        } else if (contentLengthHeader != null) {
            long contentlen = -1;
            Header[] headers = message.getHeaders(HTTP.CONTENT_LEN);
            if (strict && headers.length > 1) {
                throw new ProtocolException("Multiple content length headers");
            }
            for (int i = headers.length - 1; i >= 0; i--) {
                Header header = headers[i];
                try {
                    contentlen = Long.parseLong(header.getValue());
                    break;
                } catch (NumberFormatException e) {
                    if (strict) {
                        throw new ProtocolException("Invalid content length: " + header.getValue());
                    }
                }
                // See if we can have better luck with another header, if present
            }
            entity.setChunked(false);
            entity.setContentLength(contentlen);
            if (contentlen >= 0) {
                entity.setContent(new ContentLengthInputStream(datareceiver, contentlen));
            } else {
                entity.setContent(new HttpDataInputStream(datareceiver));
            }
        } else {
            entity.setChunked(false);
            entity.setContentLength(-1);
            entity.setContent(new HttpDataInputStream(datareceiver));                           
        }
        if (contentTypeHeader != null) {
            entity.setContentType(contentTypeHeader);   
        }
        if (contentEncodingHeader != null) {
View Full Code Here


            // The chunked encoding must be the last one applied RFC2616, 14.41
            int len = encodings.length;
            if (HTTP.IDENTITY_CODING.equalsIgnoreCase(transferEncodingHeader.getValue())) {
                entity.setChunked(false);
                entity.setContentLength(-1);
                entity.setContent(new HttpDataInputStream(datareceiver));                           
            } else if ((len > 0) && (HTTP.CHUNK_CODING.equalsIgnoreCase(
                    encodings[len - 1].getName()))) {
                entity.setChunked(true);
                entity.setContentLength(-1);
                entity.setContent(new ChunkedInputStream(datareceiver));
            } else {
                if (strict) {
                    throw new ProtocolException("Chunk-encoding must be the last one applied");
                }
                entity.setChunked(false);
                entity.setContentLength(-1);
                entity.setContent(new HttpDataInputStream(datareceiver));                           
            }
        } else if (contentLengthHeader != null) {
            long contentlen = -1;
            Header[] headers = message.getHeaders(HTTP.CONTENT_LEN);
            if (strict && headers.length > 1) {
                throw new ProtocolException("Multiple content length headers");
            }
            for (int i = headers.length - 1; i >= 0; i--) {
                Header header = headers[i];
                try {
                    contentlen = Long.parseLong(header.getValue());
                    break;
                } catch (NumberFormatException e) {
                    if (strict) {
                        throw new ProtocolException("Invalid content length: " + header.getValue());
                    }
                }
                // See if we can have better luck with another header, if present
            }
            entity.setChunked(false);
            entity.setContentLength(contentlen);
            if (contentlen >= 0) {
                entity.setContent(new ContentLengthInputStream(datareceiver, contentlen));
            } else {
                entity.setContent(new HttpDataInputStream(datareceiver));
            }
        } else {
            entity.setChunked(false);
            entity.setContentLength(-1);
            entity.setContent(new HttpDataInputStream(datareceiver));                           
        }
        if (contentTypeHeader != null) {
            entity.setContentType(contentTypeHeader);   
        }
        if (contentEncodingHeader != null) {
View Full Code Here

            entity.setContentLength(-1);
            entity.setContent(new ChunkedInputStream(datareceiver));
        } else if (len == ContentLengthStrategy.IDENTITY) {
            entity.setChunked(false);
            entity.setContentLength(-1);
            entity.setContent(new HttpDataInputStream(datareceiver));                           
        } else {
            entity.setChunked(false);
            entity.setContentLength(len);
            entity.setContent(new ContentLengthInputStream(datareceiver, len));
        }
View Full Code Here

TOP

Related Classes of org.apache.http.io.HttpDataInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.