boolean useSSl = isSecure(uri) && !useProxy;
// some headers are only set when performing the first request
HttpHeaders headers = future.getNettyRequest().getHttpRequest().headers();
Realm realm = request.getRealm() != null ? request.getRealm() : config.getRealm();
HttpMethod method = future.getNettyRequest().getHttpRequest().getMethod();
requestFactory.addAuthorizationHeader(headers, requestFactory.firstRequestOnlyAuthorizationHeader(request, uri, proxy, realm));
requestFactory.setProxyAuthorizationHeader(headers, requestFactory.firstRequestOnlyProxyAuthorizationHeader(request, proxy, method));
// Do not throw an exception when we need an extra connection for a
// redirect