public class WebResponseWrapper extends WebResponse
WebResponse interface that can be subclassed
by developers wishing to adapt a particular WebResponse.
This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped
web response object.FORBIDDEN, INTERNAL_SERVER_ERROR, NO_CONTENT, NOT_FOUND, OK| Constructor and Description |
|---|
WebResponseWrapper(WebResponse webResponse)
Constructs a WebResponse object wrapping provided WebResponse.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp()
Clean up the response data.
|
void |
defaultCharsetUtf8()
Mark this response for using UTF-8 as default charset.
|
InputStream |
getContentAsStream()
Returns the response content as an input stream.
|
InputStream |
getContentAsStreamWithBomIfApplicable()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
String |
getContentAsString()
Returns the response content as a string, using the charset/encoding specified in the server response.
|
String |
getContentAsString(Charset encoding)
Returns the response content as a string, using the specified charset,
rather than the charset/encoding specified in the server response.
|
String |
getContentAsString(Charset encoding,
boolean ignoreUtf8Bom)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns the response content as a string, using the specified charset, rather than the charset/encoding specified in the server response. |
Charset |
getContentCharset()
Returns the content charset for this response, even if no charset was specified explicitly.
|
Charset |
getContentCharsetOrNull()
Returns the content charset specified explicitly in the header or in the content,
or
null if none was specified. |
long |
getContentLength()
Returns length of the content data.
|
String |
getContentType()
Returns the content type returned from the server, e.g.
|
long |
getLoadTime()
Returns the time it took to load this web response, in milliseconds.
|
List<NameValuePair> |
getResponseHeaders()
Returns the response headers as a list of
NameValuePairs. |
String |
getResponseHeaderValue(String headerName)
Returns the value of the specified response header.
|
int |
getStatusCode()
Returns the status code that was returned by the server.
|
String |
getStatusMessage()
Returns the status message that was returned from the server.
|
WebRequest |
getWebRequest()
Returns the request used to load this response.
|
boolean |
isSuccess() |
boolean |
isSuccessOrUseProxy() |
boolean |
isSuccessOrUseProxyOrNotModified() |
public WebResponseWrapper(WebResponse webResponse) throws IllegalArgumentException
webResponse - the webResponse that does the real workIllegalArgumentException - if the webResponse is nullpublic long getContentLength()
getContentLength in class WebResponsepublic InputStream getContentAsStream() throws IOException
getContentAsStream in class WebResponseIOException - in case of IOProblemspublic String getContentAsString()
getContentAsString in class WebResponsepublic String getContentAsString(Charset encoding)
getContentAsString in class WebResponseencoding - the charset/encoding to use to convert the response content into a stringpublic String getContentAsString(Charset encoding, boolean ignoreUtf8Bom)
getContentAsString in class WebResponseencoding - the charset/encoding to use to convert the response content into a stringignoreUtf8Bom - if true utf8 bom header will be ignoredpublic Charset getContentCharsetOrNull()
null if none was specified.
The default behavior of this method is to return getContentCharsetOrNull() on the wrapped webResponse object.getContentCharsetOrNull in class WebResponsenull if none was specifiedpublic Charset getContentCharset()
Content-Type
header; if not found, it checks the request charset; as a last resort, this method
returns StandardCharsets.ISO_8859_1.
If no charset is defined for an xml response, then UTF-8 is used
The default behavior of this method is to return getContentCharset() on the wrapped webResponse object.getContentCharset in class WebResponsepublic String getContentType()
getContentType in class WebResponsepublic long getLoadTime()
getLoadTime in class WebResponsepublic List<NameValuePair> getResponseHeaders()
NameValuePairs.
The default behavior of this method is to return getResponseHeaders() on the wrapped webResponse object.getResponseHeaders in class WebResponseNameValuePairspublic String getResponseHeaderValue(String headerName)
getResponseHeaderValue in class WebResponseheaderName - the name of the header whose value is to be returnednull if no response header exists with this namepublic int getStatusCode()
getStatusCode in class WebResponsepublic String getStatusMessage()
getStatusMessage in class WebResponsepublic WebRequest getWebRequest()
getWebRequest in class WebResponsepublic void cleanUp()
cleanUp in class WebResponsepublic void defaultCharsetUtf8()
defaultCharsetUtf8 in class WebResponsepublic InputStream getContentAsStreamWithBomIfApplicable() throws IOException
WebResponsegetContentAsStreamWithBomIfApplicable in class WebResponseIOException - in case of IO problemspublic boolean isSuccess()
isSuccess in class WebResponsepublic boolean isSuccessOrUseProxy()
isSuccessOrUseProxy in class WebResponsepublic boolean isSuccessOrUseProxyOrNotModified()
isSuccessOrUseProxyOrNotModified in class WebResponseCopyright © 2002–2022 Gargoyle Software Inc.. All rights reserved.