package de.tblsoft.solr.http;

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

/**
 * Created by tblsoft on 18.03.16.
 */
public class HTTPHelper {



    public static String post(String url, String postString) {
       try {
           CloseableHttpClient httpclient = HttpClients.createDefault();
           HttpPost httpPost = new HttpPost(url);

           StringEntity entity = new StringEntity(postString, "UTF-8");
           httpPost.setEntity(entity);
           //httpPost.setHeader("Content-Type",contentType);


           CloseableHttpResponse response = httpclient.execute(httpPost);
           StringBuilder responseBuilder = new StringBuilder();

           responseBuilder.append(EntityUtils.toString(response.getEntity()));
           httpclient.close();
           return responseBuilder.toString();
       } catch (Exception e) {
           throw new RuntimeException(e);
       }
    }
}

@@ -85,16 +85,63 @@
 sponse;%0A
+import org.apache.http.client.methods.HttpGet;%0A
 import o
@@ -1199,10 +1199,588 @@
 %7D%0A    %7D%0A
+    %0A    public static String get(String url) %7B%0A        try %7B%0A            CloseableHttpClient httpclient = HttpClients.createDefault();%0A            HttpGet httpPost = new HttpGet(url);%0A%0A            CloseableHttpResponse response = httpclient.execute(httpPost);%0A            StringBuilder responseBuilder = new StringBuilder();%0A%0A            responseBuilder.append(EntityUtils.toString(response.getEntity()));%0A            httpclient.close();%0A            return responseBuilder.toString();%0A        %7D catch (Exception e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A     %7D%0A
 %7D%0A

add get method