Class RepeatableRequestEntity
- All Implemented Interfaces:
org.apache.commons.httpclient.methods.RequestEntity
This class works by taking advantage of the reset capability of the original data input stream, or by wrapping the input stream in a reset-able class if it is not so capable.
When data is repeated, any attached ProgressMonitoredInputStream
is notified
that a repeat transmission is occurring.
- Author:
- James Murty
-
Constructor Summary
ConstructorsConstructorDescriptionRepeatableRequestEntity
(String name, InputStream is, String contentType, long contentLength, Jets3tProperties jets3tProperties, boolean enableLiveMD5Hashing) Creates a repeatable request entity for the input stream provided. -
Method Summary
Modifier and TypeMethodDescriptionlong
byte[]
boolean
void
writeRequest
(OutputStream out) Writes the request to the output stream.
-
Constructor Details
-
RepeatableRequestEntity
public RepeatableRequestEntity(String name, InputStream is, String contentType, long contentLength, Jets3tProperties jets3tProperties, boolean enableLiveMD5Hashing) Creates a repeatable request entity for the input stream provided.If the input stream provided, or any underlying wrapped input streams, supports the
InputStream.reset()
method then it will be capable of repeating data transmission. If the input stream provided does not supports this method, it will automatically be wrapped in aRepeatableInputStream
-- in this case, the data read from the wrapped input stream will be buffered up to the limit set by the JetS3t property uploads.stream-retry-buffer-size (default: 131072 bytes).This constructor also detects when an underlying
ProgressMonitoredInputStream
is present, and will notify this monitor if a repeat occurs.If the JetS3t properties option
httpclient.read-throttle
is set to a non-zero value, all simultaneous uploads performed by this class will be throttled to the specified speed.- Parameters:
is
- the input stream that supplies the data to be made repeatable.contentType
-contentLength
-enableLiveMD5Hashing
- if true, data that passes through the object will be hashed to an MD5 digest and this digest will be available fromgetMD5DigestOfData()
. If false, the digest will not be calculated.
-
-
Method Details
-
getContentLength
public long getContentLength()- Specified by:
getContentLength
in interfaceorg.apache.commons.httpclient.methods.RequestEntity
-
getContentType
- Specified by:
getContentType
in interfaceorg.apache.commons.httpclient.methods.RequestEntity
-
isRepeatable
public boolean isRepeatable()- Specified by:
isRepeatable
in interfaceorg.apache.commons.httpclient.methods.RequestEntity
- Returns:
- always returns true.
If the input stream is not actually repeatable, an IOException will be thrown
later by the
writeRequest(OutputStream)
method when the repeat is attempted.
-
writeRequest
Writes the request to the output stream. If the request is being repeated, the underlying repeatable input stream will be reset with a call toInputStream.reset()
.If a
ProgressMonitoredInputStream
is attached, this monitor will be notified that data is being repeated by being reset withProgressMonitoredInputStream.resetProgressMonitor()
.- Specified by:
writeRequest
in interfaceorg.apache.commons.httpclient.methods.RequestEntity
- Throws:
IOException
-
getMD5DigestOfData
public byte[] getMD5DigestOfData()- Returns:
- The MD5 digest of the data transmitted by this RequestEntity.
-