public class HttpUtils extends Object
| Constructor and Description |
|---|
HttpUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
buildDefaultErrorMessage(SlingHttpResponse resp)
Build default error message
|
static int[] |
getExpectedStatus(int defaultStatus,
int... expectedStatus) |
static int |
getHttpStatus(org.apache.http.HttpResponse response)
Get HTTP Status of the response.
|
static String |
getLocationHeader(org.apache.http.HttpResponse response)
Get the first 'Location' header and verify it's a valid URI.
|
static boolean |
isInHttpStatusRange(org.apache.http.HttpResponse response,
int range)
Check if expected status is in range
|
static void |
verifyHttpStatus(org.apache.http.HttpResponse response,
String errorMessage,
int... expectedStatus)
Verify expected status and show error message in case expected status is not returned.
|
static void |
verifyHttpStatus(SlingHttpResponse response,
int... expectedStatus)
Verify expected status and dump response in case expected status is not returned.
|
public static void verifyHttpStatus(SlingHttpResponse response, int... expectedStatus) throws ClientException
response - The Sling HTTP responseexpectedStatus - List of acceptable HTTP StatusesClientException - if status is not expectedpublic static void verifyHttpStatus(org.apache.http.HttpResponse response,
String errorMessage,
int... expectedStatus)
throws ClientException
response - The SlingHttpResponse of an executed request.errorMessage - error message; if null, errorMessage is extracted from responseexpectedStatus - List of acceptable HTTP StatusesClientException - if status is not expectedpublic static String buildDefaultErrorMessage(SlingHttpResponse resp)
resp - The response of a sling requestpublic static int getHttpStatus(org.apache.http.HttpResponse response)
throws ClientException
response - The RequestExecutor of an executed request.ClientException - never (kept for uniformity)public static String getLocationHeader(org.apache.http.HttpResponse response) throws ClientException
response - HttpResponse the http responseClientException - never (kept for uniformity)public static boolean isInHttpStatusRange(org.apache.http.HttpResponse response,
int range)
response - the http responserange - the http status rangepublic static int[] getExpectedStatus(int defaultStatus,
int... expectedStatus)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.