private AlgoResponse pipeRequest(String input, ContentType content_type) throws APIException { try { return pipeRequestAsync(input, content_type).get(); } catch (java.util.concurrent.ExecutionException e) { throw new APIException(e.getCause().getMessage()); } catch (java.util.concurrent.CancellationException e) { throw new APIException( "API connection cancelled: " + algoRef.getUrl() + " (" + e.getMessage() + ")", e); } catch (java.lang.InterruptedException e) { throw new APIException( "API connection interrupted: " + algoRef.getUrl() + " (" + e.getMessage() + ")", e); } }
private FutureAlgoResponse pipeBinaryRequestAsync(byte[] input) { Future<AlgoResponse> promise = client.post( algoRef.getUrl(), new ByteArrayEntity(input, org.apache.http.entity.ContentType.APPLICATION_OCTET_STREAM), new AlgoResponseHandler()); return new FutureAlgoResponse(promise); }
private FutureAlgoResponse pipeRequestAsync(String input, ContentType content_type) { StringEntity requestEntity = null; if (content_type == ContentType.Text) { requestEntity = new StringEntity(input, "UTF-8"); } else if (content_type == ContentType.Json) { requestEntity = new StringEntity(input, org.apache.http.entity.ContentType.APPLICATION_JSON); } Future<AlgoResponse> promise = client.post(algoRef.getUrl(), requestEntity, new AlgoResponseHandler()); return new FutureAlgoResponse(promise); }