FileDocCategorySizeDatePackage
BufferedHttpEntity.javaAPI DocAndroid 1.5 API3861Wed May 06 22:41:10 BST 2009org.apache.http.entity

BufferedHttpEntity

public class BufferedHttpEntity extends HttpEntityWrapper
A wrapping entity that buffers it content if necessary. The buffered entity is always repeatable. If the wrapped entity is repeatable itself, calls are passed through. If the wrapped entity is not repeatable, the content is read into a buffer once and provided from there as often as required.
author
Oleg Kalnichevski
version
$Revision: 496070 $
since
4.0

Fields Summary
private final byte[]
buffer
Constructors Summary
public BufferedHttpEntity(HttpEntity entity)

        super(entity);
        if (!entity.isRepeatable() || entity.getContentLength() < 0) {
            this.buffer = EntityUtils.toByteArray(entity);
        } else {
            this.buffer = null;
        }
    
Methods Summary
public java.io.InputStreamgetContent()

        if (this.buffer != null) {
            return new ByteArrayInputStream(this.buffer);
        } else {
            return wrappedEntity.getContent();
        }
    
public longgetContentLength()

        if (this.buffer != null) {
            return this.buffer.length;
        } else {
            return wrappedEntity.getContentLength();
        }
    
public booleanisChunked()
Tells that this entity does not have to be chunked.

return
false

        return (buffer == null) && wrappedEntity.isChunked();
    
public booleanisRepeatable()
Tells that this entity is repeatable.

return
true

        return true;
    
public booleanisStreaming()

        return (buffer == null) && wrappedEntity.isStreaming();
    
public voidwriteTo(java.io.OutputStream outstream)

        if (outstream == null) {
            throw new IllegalArgumentException("Output stream may not be null");
        }
        if (this.buffer != null) {
            outstream.write(this.buffer);
        } else {
            wrappedEntity.writeTo(outstream);
        }