public final class HttpResponseUtils extends Object
Modifier and Type | Method and Description |
---|---|
static org.apache.http.entity.ContentType |
getContentType(org.apache.http.client.methods.CloseableHttpResponse response) |
static String |
getFirstHeader(String headerName,
org.apache.http.HttpResponse httpResponse)
Get the value of the first header matching "headerName".
|
static boolean |
isError(org.apache.http.HttpResponse httpResponse)
Check if httpResponse has an error status.
|
static String |
removeSessionId(String uri,
org.apache.http.HttpResponse httpResponse)
Removes ";jsessionid=<id>" from the url, if the session id is also set in "httpResponse".
|
static String |
toString(org.apache.http.client.methods.CloseableHttpResponse response) |
static String |
toString(org.apache.http.HttpResponse httpResponse,
EventManager eventManager)
Returns the response body as a string or the reason phrase if body is empty.
|
static void |
writeTo(org.apache.http.HttpEntity httpEntity,
OutputStream outstream)
Copied from org.apache.http.entity.InputStreamEntity.writeTo(OutputStream) method but flushes the buffer after
each read in order to allow streaming and web sockets.
|
public static boolean isError(org.apache.http.HttpResponse httpResponse)
httpResponse
- tge HttpResponse
public static String getFirstHeader(String headerName, org.apache.http.HttpResponse httpResponse)
headerName
- httpResponse
- public static String removeSessionId(String uri, org.apache.http.HttpResponse httpResponse)
This methods first looks for the following header :
Set-Cookie: JSESSIONID=If found and perfectly matches the jsessionid value in url, the complete jsessionid definition is removed from the url.
uri
- original uri, may contains a jsessionid.httpResponse
- the response which set the jsessionIdpublic static String toString(org.apache.http.HttpResponse httpResponse, EventManager eventManager) throws HttpErrorPage
This methods is similar to EntityUtils#toString() internally, but uncompress the entity first if necessary.
This methods also holds an extension point, which can be used to guess the real encoding of the entity, if the HTTP headers set a wrong encoding declaration.
httpResponse
- eventManager
- HttpErrorPage
public static org.apache.http.entity.ContentType getContentType(org.apache.http.client.methods.CloseableHttpResponse response)
public static String toString(org.apache.http.client.methods.CloseableHttpResponse response) throws HttpErrorPage
HttpErrorPage
public static void writeTo(org.apache.http.HttpEntity httpEntity, OutputStream outstream) throws IOException
httpEntity
- The entity to copy to the OutputStreamoutstream
- The OutputStreamIOException
- If a problem occursCopyright © 2008–2018. All rights reserved.