use of com.microsoft.azure.hdinsight.common.HttpResponseWithoutHeader in project azure-tools-for-java by Microsoft.
the class RestTask method getResultFromHttpResponse.
private static HttpResponseWithoutHeader getResultFromHttpResponse(@NotNull CloseableHttpResponse response) throws IOException {
int code = response.getStatusLine().getStatusCode();
String reason = response.getStatusLine().getReasonPhrase();
HttpEntity entity = response.getEntity();
try (InputStream inputStream = entity.getContent()) {
String response_content = getResultFromInputStream(inputStream);
return new HttpResponseWithoutHeader(code, response_content, reason);
}
}
use of com.microsoft.azure.hdinsight.common.HttpResponseWithoutHeader in project azure-tools-for-java by Microsoft.
the class RestTask method call.
@Override
public String call() throws Exception {
CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
HttpGet httpGet = new HttpGet(path);
httpGet.addHeader("Content-Type", "application/json");
CloseableHttpResponse response = httpclient.execute(httpGet);
HttpResponseWithoutHeader header = getResultFromHttpResponse(response);
if (header.getStatusCode() == 200 || header.getStatusCode() == 201) {
return header.getMessage();
} else {
throw new HDIException(header.getReason(), header.getStatusCode());
}
}
Aggregations