use of org.ow2.proactive.http.HttpClientBuilder in project scheduling by ow2-proactive.
the class AbstractCommand method execute.
protected HttpResponseWrapper execute(HttpUriRequest request, ApplicationContext currentContext) {
String sessionId = currentContext.getSessionId();
if (sessionId != null) {
request.setHeader("sessionid", sessionId);
}
CommonHttpClientBuilder httpClientBuilder = new HttpClientBuilder().useSystemProperties();
try {
if ("https".equals(request.getURI().getScheme()) && currentContext.canInsecureAccess()) {
httpClientBuilder.insecure(true);
}
HttpResponse response = httpClientBuilder.build().execute(request);
return new HttpResponseWrapper(response);
} catch (SSLPeerUnverifiedException sslException) {
throw new CLIException(CLIException.REASON_OTHER, "SSL error. Perhaps HTTPS certificate could not be validated, " + "you can try with -k or insecure() for insecure SSL connection.", sslException);
} catch (Exception e) {
throw new CLIException(CLIException.REASON_OTHER, e.getMessage(), e);
} finally {
((HttpRequestBase) request).releaseConnection();
}
}
Aggregations