|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.jdesktop.http.Response
public class Response extends Object
Represents a Response from an http Request. Instances of this class
are created as a result of executing a Request in a Session.
They are not created manually.
Responses can access all of the http Headers that were
returned with the response, as well as the status code, status message, and
response body. In addition, the url that this response originated from is
available. This is useful when constructing further requests based on relative
url paths.
As with Request, the body of the Response is
treated specially. Since the response may be very large (like, say, downloading
an operating system) it is critical that the responses not be cached. As a
result, once the response body has been read, any futher calls to getResponseBody
may result in an exception.
| Field Summary | |
|---|---|
private String |
charset
The encoding for the body to be used when constructing a String from the bytes. |
private Set |
headers
|
private byte[] |
responseBody
|
private StatusCode |
statusCode
|
private String |
statusText
|
private String |
url
|
| Constructor Summary | |
Response(StatusCode statusCode, String statusText, byte[] responseBody, String charset, Set headers, String baseUrl)
|
|
| Method Summary | |
|---|---|
String
|
getBaseUrl()
Gets the url that was used to produce this |
String
|
getBody()
|
byte[]
|
getBodyAsBytes()
Gets a byte array representing the body of the response. |
Reader
|
getBodyAsReader()
|
InputStream
|
getBodyAsStream()
|
Header
|
getHeader(String name)
Returns the Header with the given name, or null if there is no such header. |
Header[]
|
getHeaders()
Gets an array of all the Headers for this Request. |
Date
|
getLastModified()
|
StatusCode
|
getStatusCode()
Gets the status code. |
String
|
getStatusText()
|
String
|
toString()
|
| Methods inherited from class Object | |
|---|---|
| wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Field Detail |
|---|
private String charset
private Set headers
private byte[] responseBody
private StatusCode statusCode
private String statusText
private String url
| Constructor Detail |
|---|
Response(StatusCode statusCode, String statusText, byte[] responseBody, String charset, Set headers, String baseUrl)
| Method Detail |
|---|
public String getBaseUrl()
Response. This
url will not contain a query string (that is, no parameters).
public String getBody()
public byte[] getBodyAsBytes()
public Reader getBodyAsReader()
public InputStream getBodyAsStream()
public Header getHeader(String name)
name - the name to look for. This must not be null.
public Header[] getHeaders()
public Date getLastModified()
public StatusCode getStatusCode()
public String getStatusText()
buffer.append(getBody()); public String toString()
Groovy Documentation