public abstract class HttpResponseUtils extends Object
org.apache.commons.httpclient.HttpMethodBase.java in httpclient 3.x.| Constructor and Description |
|---|
HttpResponseUtils() |
| Modifier and Type | Method and Description |
|---|---|
static long |
getContentLength(org.apache.http.HttpResponse resp)
Return the length (in bytes) of the response body, as specified in a
Content-Length header.
|
static byte[] |
getResponseBody(org.apache.http.HttpResponse resp)
Returns the response body of the HTTPResponse, if any, as an array of bytes.
|
static String |
getResponseBodyAsString(org.apache.http.HttpResponse resp)
Returns the response body of the HTTPResponse, if any, as a
String. |
public static byte[] getResponseBody(org.apache.http.HttpResponse resp)
throws IOException
resp - HttpResponseIOException - If an I/O (transport) problem occurs while obtaining
the response body.public static String getResponseBodyAsString(org.apache.http.HttpResponse resp) throws IOException
String.
If response body is not available or cannot be read, returns null
The string conversion on the data is done using UTF-8.
Note: This will cause the entire response body to be buffered in memory. A
malicious server may easily exhaust all the VM memory. It is strongly
recommended, to use getResponseAsStream if the content length of the
response is unknown or reasonably large.resp - HttpResponseIOException - If an I/O (transport) problem occurs while obtaining
the response body.public static long getContentLength(org.apache.http.HttpResponse resp)
Return -1 when the content-length is unknown.
resp - HttpResponseCopyright © 2008–2021 Apache Software Foundation. All rights reserved.