use of com.alibaba.nacos.common.http.client.response.DefaultClientHttpResponse in project nacos by alibaba.
the class DefaultAsyncHttpClientRequest method execute.
@Override
public <T> void execute(URI uri, String httpMethod, RequestHttpEntity requestHttpEntity, final ResponseHandler<T> responseHandler, final Callback<T> callback) throws Exception {
HttpRequestBase httpRequestBase = DefaultHttpClientRequest.build(uri, httpMethod, requestHttpEntity);
asyncClient.execute(httpRequestBase, new FutureCallback<HttpResponse>() {
@Override
public void completed(HttpResponse result) {
DefaultClientHttpResponse response = new DefaultClientHttpResponse(result);
try {
HttpRestResult<T> httpRestResult = responseHandler.handle(response);
callback.onReceive(httpRestResult);
} catch (Exception e) {
callback.onError(e);
} finally {
HttpClientUtils.closeQuietly(result);
}
}
@Override
public void failed(Exception ex) {
callback.onError(ex);
}
@Override
public void cancelled() {
callback.onCancel();
}
});
}
use of com.alibaba.nacos.common.http.client.response.DefaultClientHttpResponse in project nacos by alibaba.
the class DefaultHttpClientRequest method execute.
@Override
public HttpClientResponse execute(URI uri, String httpMethod, RequestHttpEntity requestHttpEntity) throws Exception {
HttpRequestBase request = build(uri, httpMethod, requestHttpEntity, defaultConfig);
CloseableHttpResponse response = client.execute(request);
return new DefaultClientHttpResponse(response);
}
Aggregations