@Override public RawResponse makeGetRequest(String url) { HttpGet httpGet = new HttpGet(url); return executeRequest(httpGet); }
private RawResponse executeRequest(HttpUriRequest httpRequest) { try { return getHttpClient().execute(httpRequest, new ResponseHandler<RawResponse>() { @Override public RawResponse handleResponse(HttpResponse response) throws IOException { int statusCode = response.getStatusLine().getStatusCode(); String statusMessage = response.getStatusLine().getReasonPhrase(); String content = EntityUtils.toString(response.getEntity(), UTF_8); Long consulIndex = parseUnsignedLong(response.getFirstHeader("X-Consul-Index")); Boolean consulKnownLeader = parseBoolean(response.getFirstHeader("X-Consul-Knownleader")); Long consulLastContact = parseUnsignedLong(response.getFirstHeader("X-Consul-Lastcontact")); return new RawResponse(statusCode, statusMessage, content, consulIndex, consulKnownLeader, consulLastContact); } }); } catch (IOException e) { throw new TransportException(e); } }
private RawResponse executeRequest(HttpUriRequest httpRequest) { try { return getHttpClient().execute(httpRequest, new ResponseHandler<RawResponse>() { @Override public RawResponse handleResponse(HttpResponse response) throws IOException { int statusCode = response.getStatusLine().getStatusCode(); String statusMessage = response.getStatusLine().getReasonPhrase(); String content = EntityUtils.toString(response.getEntity(), UTF_8); Long consulIndex = parseUnsignedLong(response.getFirstHeader("X-Consul-Index")); Boolean consulKnownLeader = parseBoolean(response.getFirstHeader("X-Consul-Knownleader")); Long consulLastContact = parseUnsignedLong(response.getFirstHeader("X-Consul-Lastcontact")); return new RawResponse(statusCode, statusMessage, content, consulIndex, consulKnownLeader, consulLastContact); } }); } catch (IOException e) { throw new TransportException(e); } }
@Override public RawResponse makeDeleteRequest(String url) { HttpDelete httpDelete = new HttpDelete(url); return executeRequest(httpDelete); }
@Override public RawResponse makeGetRequest(String url) { HttpGet httpGet = new HttpGet(url); return executeRequest(httpGet); }
@Override public RawResponse makeDeleteRequest(String url) { HttpDelete httpDelete = new HttpDelete(url); return executeRequest(httpDelete); }
@Override public RawResponse makePutRequest(String url, String content) { HttpPut httpPut = new HttpPut(url); httpPut.setEntity(new StringEntity(content, UTF_8)); return executeRequest(httpPut); }
@Override public RawResponse makePutRequest(String url, byte[] content) { HttpPut httpPut = new HttpPut(url); httpPut.setEntity(new ByteArrayEntity(content)); return executeRequest(httpPut); }
@Override public RawResponse makePutRequest(String url, byte[] content) { HttpPut httpPut = new HttpPut(url); httpPut.setEntity(new ByteArrayEntity(content)); return executeRequest(httpPut); }
@Override public RawResponse makePutRequest(String url, String content) { HttpPut httpPut = new HttpPut(url); httpPut.setEntity(new StringEntity(content, UTF_8)); return executeRequest(httpPut); }