- public static String post(String url, Map<String, String> header, Map<String, String> param,
- HttpEntity entity) throws Exception {
- String result = "";
- CloseableHttpClient httpClient = null;
- try {
- httpClient = getHttpClient();
- HttpPost httpPost = new HttpPost(url);
- if (!header.isEmpty()) {
- for (Map.Entry<String, String> entry : header.entrySet()) {
- httpPost.addHeader(entry.getKey(), entry.getValue());
- }
+ public static HttpResponse get(HttpGet httpGet, Map<String, String> header, CloseableHttpClient httpClient) throws CorrelationException {
+ return getGetAndDeleteResponse(httpGet, header, httpClient);
+ }
+
+ public static HttpResponse post(HttpPost httpPost, Map<String, String> header, Map<String, String> param,
+ HttpEntity entity, CloseableHttpClient httpClient) throws CorrelationException {
+ return getPostAndPutResponse(httpPost, header, param, entity, httpClient);
+ }
+
+ public static HttpResponse put(HttpPut httpPut, Map<String, String> header, Map<String, String> param,
+ HttpEntity entity, CloseableHttpClient httpClient) throws CorrelationException {
+ return getPostAndPutResponse(httpPut, header, param, entity, httpClient);
+ }
+
+ public static HttpResponse delete(HttpDelete httpDelete, Map<String, String> header, CloseableHttpClient httpClient) throws CorrelationException {
+ return getGetAndDeleteResponse(httpDelete, header, httpClient);
+ }
+
+ private static void addParams(Map<String, String> param, HttpEntityEnclosingRequestBase requestBase) {
+ if (!param.isEmpty()) {
+ List<NameValuePair> formparams = new ArrayList<>();
+ for (Map.Entry<String, String> entry : param.entrySet()) {
+ formparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));