|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codegist.crest.HttpResponse
public class HttpResponse
Http response for the a HttpRequest.
Response charset and mime type are retrieved on the Content-Type header.
If no valid charset and mimetype are found, it defaults respectively with ISO-8859-1 and text/html
If the response is GZipped, the Content-Encoding header must be set to gzip.
Constructor Summary | |
---|---|
HttpResponse(HttpRequest request,
int statusCode)
|
|
HttpResponse(HttpRequest request,
int statusCode,
Map<String,List<String>> headers)
|
|
HttpResponse(HttpRequest request,
int statusCode,
Map<String,List<String>> headers,
HttpResource resource)
|
Method Summary | |
---|---|
Reader |
asReader()
Get the response reader using the response charset (extracted from response header.) |
InputStream |
asStream()
Get the response input stream. |
String |
asString()
Returns the response as string. |
void |
close()
Close the response. |
Charset |
getCharset()
|
String |
getContentEncoding()
|
List<String> |
getHeader(String name)
|
String |
getMimeType()
|
HttpRequest |
getRequest()
|
int |
getStatusCode()
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HttpResponse(HttpRequest request, int statusCode)
public HttpResponse(HttpRequest request, int statusCode, Map<String,List<String>> headers)
public HttpResponse(HttpRequest request, int statusCode, Map<String,List<String>> headers, HttpResource resource)
request
- The original requeststatusCode
- the response status codeheaders
- response headers.resource
- underlying http resourceMethod Detail |
---|
public String getMimeType()
public Charset getCharset()
public String getContentEncoding()
public HttpRequest getRequest()
public Reader asReader() throws IllegalStateException
IllegalStateException
- if asString()
has already been calledpublic InputStream asStream()
getCharset()
to decode it.
IllegalStateException
- if asString()
has already been calledpublic String asString()
asReader()
or asStream()
will throw an IllegalStateException.
Can only be called if the reponse stream hasn't been consumed.
public List<String> getHeader(String name)
public int getStatusCode()
public void close()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |