use of aQute.bnd.service.url.ProxyHandler.ProxySetup in project bnd by bndtools.
the class HttpClient method send0.
public TaggedData send0(final HttpRequest<?> request) throws Exception {
final ProxySetup proxy = getProxySetup(request.url);
final URLConnection con = getProxiedAndConfiguredConnection(request.url, proxy);
final HttpURLConnection hcon = (HttpURLConnection) (con instanceof HttpURLConnection ? con : null);
if (request.ifNoneMatch != null) {
request.headers.put("If-None-Match", entitytag(request.ifNoneMatch));
}
if (request.ifMatch != null) {
request.headers.put("If-Match", "\"" + entitytag(request.ifMatch));
}
if (request.ifModifiedSince > 0) {
request.headers.put("If-Modified-Since", httpDateFormat().format(new Date(request.ifModifiedSince)));
}
if (request.ifUnmodifiedSince != 0) {
request.headers.put("If-Unmodified-Since", httpDateFormat().format(new Date(request.ifUnmodifiedSince)));
}
setHeaders(request.headers, con);
configureHttpConnection(request.verb, hcon);
final ProgressPlugin.Task task = getTask(request);
try {
TaggedData td = connectWithProxy(proxy, new Callable<TaggedData>() {
@Override
public TaggedData call() throws Exception {
return doConnect(request.upload, request.download, con, hcon, request, task);
}
});
logger.debug("result {}", td);
return td;
} catch (Throwable t) {
task.done("Failed " + t, t);
throw t;
}
}
Aggregations