public final class HTTPCallResult extends CallResult implements HTTPCallResultData
Constructor and Description |
---|
HTTPCallResult(HTTPCallRequest request,
TargetDescriptor succeededTarget,
long duration,
List<CallException> exceptions,
HTTPCallResultData data)
Constructs a new
HTTPCallResult object. |
Modifier and Type | Method and Description |
---|---|
byte[] |
getData()
Returns the result data as a byte array.
|
int |
getStatusCode()
Returns the HTTP status code.
|
InputStream |
getStream()
Returns the returned data as an
InputStream . |
String |
getString()
Returns the returned data as a
String . |
String |
getString(String encoding)
Returns the returned data as a
String in the specified
encoding. |
getDuration, getExceptions, getRequest, getSucceededTarget
public HTTPCallResult(HTTPCallRequest request, TargetDescriptor succeededTarget, long duration, List<CallException> exceptions, HTTPCallResultData data) throws IllegalArgumentException
HTTPCallResult
object.request
- the call request that resulted in this result, cannot be
null
.succeededTarget
- the target for which the call succeeded, cannot be null
.duration
- the call duration in milliseconds, must be a non-negative number.exceptions
- the list of CallExceptionList
s, or null
if the
first call attempt succeeded.data
- the HTTPCallResultData
object returned from the call, cannot
be null
.IllegalArgumentException
- if request == null
|| succeededTarget == null
|| data == null
|| duration < 0L
.public int getStatusCode()
getStatusCode
in interface HTTPCallResultData
public byte[] getData()
getData
in interface HTTPCallResultData
null
.public String getString()
String
. The encoding
US-ASCII
is assumed.null
.public String getString(String encoding) throws UnsupportedEncodingException
String
in the specified
encoding.encoding
- the encoding to use in the conversion from bytes to a text string,
not null
.null
.UnsupportedEncodingException
- if the specified encoding is not supported.public InputStream getStream()
InputStream
. The input
stream is based directly on the underlying byte array.InputStream
that returns the returned data, never
null
.See http://www.xins.org/.