List of usage examples for org.apache.http.client.methods HttpGetWithEntity setEntity
public void setEntity(final HttpEntity entity)
From source file:org.nuxeo.elasticsearch.http.readonly.HttpClient.java
public static String get(String url, String payload) throws IOException { if (payload == null) { return get(url); }/*from www. jav a 2 s . c o m*/ CloseableHttpClient client = HttpClients.createDefault(); HttpGetWithEntity e = new HttpGetWithEntity(url); StringEntity myEntity = new StringEntity(payload, ContentType.create(MediaType.APPLICATION_FORM_URLENCODED, UTF8_CHARSET)); e.setEntity(myEntity); try (CloseableHttpResponse response = client.execute(e)) { HttpEntity entity = response.getEntity(); return entity != null ? EntityUtils.toString(entity) : null; } }