public class HttpUtils extends CommonUtils
| Constructor and Description |
|---|
HttpUtils() |
| Modifier and Type | Method and Description |
|---|---|
protected static Boolean |
checkHttpResponse(org.apache.http.HttpResponse actualResponse,
int expectedResponseCode)
Helper to check the actual Result Vs expected
|
static org.apache.http.HttpEntity |
executeRequest(org.apache.http.client.HttpClient client,
org.apache.http.client.methods.HttpGet request) |
static org.apache.http.HttpResponse |
executeRequest(org.apache.http.client.HttpClient client,
org.apache.http.client.methods.HttpPost request) |
static org.apache.http.HttpResponse |
executeRequestHttpResp(org.apache.http.client.HttpClient client,
org.apache.http.client.methods.HttpRequestBase request) |
static org.apache.http.client.methods.HttpDelete |
generateDeleteRequest(String requestURL,
String[] headers,
String[] reqBody) |
static org.apache.http.client.methods.HttpGet |
generateGetRequest(String requestURL,
String[] headers) |
static org.apache.http.client.methods.HttpPost |
generatePostRequest(String requestURL,
String[] headers,
org.json.JSONObject reqBody) |
static org.apache.http.client.methods.HttpPost |
generatePostRequest(String requestURL,
String[] headers,
String[] reqBody) |
static org.apache.http.client.methods.HttpPut |
generatePutRequest(String requestURL,
String[] headers,
String[] reqBody) |
String |
getHeaderKey() |
static org.apache.http.client.HttpClient |
getHttpClientWithBasicAuth(String username,
String password) |
static org.apache.http.client.HttpClient |
getHttpClientWithBasicAuth(String apiUrl,
String username,
String password) |
static String |
getParameterValue(String entity,
String paramName,
String response) |
String[] |
getRequestHeaders(String contentType) |
static String |
readStream(InputStream stream)
Reads input stream.
|
protected static void |
releaseConnection(org.apache.http.client.HttpClient client,
org.apache.http.HttpEntity entity) |
protected static void |
releaseResources(org.apache.http.client.methods.HttpRequestBase request,
org.apache.http.HttpResponse response) |
static org.apache.http.entity.StringEntity |
setMessageBody(org.json.JSONObject json)
Populate HTTP message call with given content.
|
static org.apache.http.entity.StringEntity |
setMessageBody(String content)
Populate HTTP message call with given content.
|
checkMandotaryParam, compareObjectspublic String getHeaderKey()
public static org.apache.http.client.HttpClient getHttpClientWithBasicAuth(String apiUrl, String username, String password)
public static org.apache.http.client.HttpClient getHttpClientWithBasicAuth(String username, String password)
protected static void releaseResources(org.apache.http.client.methods.HttpRequestBase request,
org.apache.http.HttpResponse response)
public static org.apache.http.client.methods.HttpPost generatePostRequest(String requestURL, String[] headers, String[] reqBody) throws Exception
Exceptionpublic static org.apache.http.client.methods.HttpPost generatePostRequest(String requestURL, String[] headers, org.json.JSONObject reqBody) throws Exception
Exceptionpublic static org.apache.http.client.methods.HttpPut generatePutRequest(String requestURL, String[] headers, String[] reqBody) throws Exception
Exceptionpublic static org.apache.http.client.methods.HttpGet generateGetRequest(String requestURL, String[] headers) throws Exception
Exceptionpublic static String getParameterValue(String entity, String paramName, String response) throws Exception
Exceptionpublic static org.apache.http.HttpResponse executeRequest(org.apache.http.client.HttpClient client,
org.apache.http.client.methods.HttpPost request)
throws Exception
Exceptionpublic static org.apache.http.HttpEntity executeRequest(org.apache.http.client.HttpClient client,
org.apache.http.client.methods.HttpGet request)
throws Exception
Exceptionpublic static org.apache.http.HttpResponse executeRequestHttpResp(org.apache.http.client.HttpClient client,
org.apache.http.client.methods.HttpRequestBase request)
throws Exception
Exceptionprotected static void releaseConnection(org.apache.http.client.HttpClient client,
org.apache.http.HttpEntity entity)
throws Exception
Exceptionprotected static Boolean checkHttpResponse(org.apache.http.HttpResponse actualResponse, int expectedResponseCode)
HttpResponse - actualResponseint - expectedResponseCodepublic static org.apache.http.client.methods.HttpDelete generateDeleteRequest(String requestURL, String[] headers, String[] reqBody) throws Exception
Exceptionpublic static String readStream(InputStream stream)
stream - InputStreampublic static org.apache.http.entity.StringEntity setMessageBody(String content) throws UnsupportedEncodingException
content - String contentStringEntity content.UnsupportedEncodingException - if unsupportedpublic static org.apache.http.entity.StringEntity setMessageBody(org.json.JSONObject json)
throws UnsupportedEncodingException
json - JSONObject contentStringEntity content.UnsupportedEncodingException - if unsupportedCopyright © 2005–2016 Alfresco Software. All rights reserved.