org.apache.http.entity
Class InputStreamEntityHC4

java.lang.Object
  extended by org.apache.http.entity.AbstractHttpEntityHC4
      extended by org.apache.http.entity.InputStreamEntityHC4
All Implemented Interfaces:
org.apache.http.HttpEntity

@NotThreadSafe
public class InputStreamEntityHC4
extends AbstractHttpEntityHC4

A streamed, non-repeatable entity that obtains its content from an InputStream.

Since:
4.0

Field Summary
 
Fields inherited from class org.apache.http.entity.AbstractHttpEntityHC4
chunked, contentEncoding, contentType, OUTPUT_BUFFER_SIZE
 
Constructor Summary
InputStreamEntityHC4(java.io.InputStream instream)
          Creates an entity with an unknown length.
InputStreamEntityHC4(java.io.InputStream instream, ContentType contentType)
          Creates an entity with a content type and unknown length.
InputStreamEntityHC4(java.io.InputStream instream, long length)
          Creates an entity with a specified content length.
InputStreamEntityHC4(java.io.InputStream instream, long length, ContentType contentType)
           
 
Method Summary
 java.io.InputStream getContent()
           
 long getContentLength()
           
 boolean isRepeatable()
           
 boolean isStreaming()
           
 void writeTo(java.io.OutputStream outstream)
          Writes bytes from the InputStream this entity was constructed with to an OutputStream.
 
Methods inherited from class org.apache.http.entity.AbstractHttpEntityHC4
consumeContent, getContentEncoding, getContentType, isChunked, setChunked, setContentEncoding, setContentEncoding, setContentType, setContentType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputStreamEntityHC4

public InputStreamEntityHC4(java.io.InputStream instream)
Creates an entity with an unknown length. Equivalent to new InputStreamEntityHC4(instream, -1).

Parameters:
instream - input stream
Throws:
java.lang.IllegalArgumentException - if instream is null
Since:
4.3

InputStreamEntityHC4

public InputStreamEntityHC4(java.io.InputStream instream,
                            long length)
Creates an entity with a specified content length.

Parameters:
instream - input stream
length - of the input stream, -1 if unknown
Throws:
java.lang.IllegalArgumentException - if instream is null

InputStreamEntityHC4

public InputStreamEntityHC4(java.io.InputStream instream,
                            ContentType contentType)
Creates an entity with a content type and unknown length. Equivalent to new InputStreamEntityHC4(instream, -1, contentType).

Parameters:
instream - input stream
contentType - content type
Throws:
java.lang.IllegalArgumentException - if instream is null
Since:
4.3

InputStreamEntityHC4

public InputStreamEntityHC4(java.io.InputStream instream,
                            long length,
                            ContentType contentType)
Parameters:
instream - input stream
length - of the input stream, -1 if unknown
contentType - for specifying the Content-Type header, may be null
Throws:
java.lang.IllegalArgumentException - if instream is null
Since:
4.2
Method Detail

isRepeatable

public boolean isRepeatable()

getContentLength

public long getContentLength()
Returns:
the content length or -1 if unknown

getContent

public java.io.InputStream getContent()
                               throws java.io.IOException
Throws:
java.io.IOException

writeTo

public void writeTo(java.io.OutputStream outstream)
             throws java.io.IOException
Writes bytes from the InputStream this entity was constructed with to an OutputStream. The content length determines how many bytes are written. If the length is unknown (-1), the stream will be completely consumed (to the end of the stream).

Throws:
java.io.IOException

isStreaming

public boolean isStreaming()