public interface Response
Response
instance is used to retrieve the result of a request on a Resource
.
Requests on these resources are asynchronous, so, before accessing the result code or data, it is necessary to
check that the request is terminated by calling isDone()
.
Example of use:
Response resp = resource.get(...);
while (!resp.isDone()) {
Thread.sleep(xxx);
resp.poll();
}
byte[] data = resp.getBody();
...
Modifier and Type | Method and Description |
---|---|
byte[] |
getBody()
Get HTTP response message body.
|
java.util.Map<java.lang.String,java.lang.String> |
getHeaders() |
java.lang.String |
getPath()
Get request message Path.
|
java.lang.String |
getRequestId()
Returns the message id of the http request that this is a response for.
|
int |
getStatusCode()
Returns the HTTP status code
|
boolean |
isDone()
Call
isDone to determine if the response is complete. |
void |
poll()
This method is used to look for an available response.
|
int getStatusCode()
java.lang.IllegalStateException
- if the response is not complete.java.lang.String getRequestId()
java.lang.String getPath()
null
byte[] getBody() throws java.lang.IllegalStateException
null
java.lang.IllegalStateException
- if the response is not complete.isDone()
java.util.Map<java.lang.String,java.lang.String> getHeaders() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if the response is not complete.isDone()
boolean isDone()
isDone
to determine if the response is complete.
Resource requests to the cloud service can be asynchronous. Before
obtaining the body isDone
must be called and return true
before calling getBody
, getBodyString
or
getHeaders
.
If isDone()
returns false
the application must call poll()
to try to update the response.false
otherwise.void poll() throws java.io.IOException, java.security.GeneralSecurityException
isDone()
has returned false
.java.io.IOException
- if network error occursjava.security.GeneralSecurityException
- when key or signature algorithm class
cannot be loaded, or the key is not in
the trusted assets store, or the
private key is invalid