Small tweaks to MinimalHttpClient

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1430867 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2013-01-09 14:12:11 +00:00
parent aa92e0e96d
commit 40bf945d04
1 changed files with 4 additions and 14 deletions

View File

@ -79,12 +79,6 @@ class MinimalHttpClient extends CloseableHttpClient {
this.params = new BasicHttpParams(); this.params = new BasicHttpParams();
} }
private HttpClientContext setupContext(final HttpContext localContext) {
HttpClientContext context = HttpClientContext.adapt(
localContext != null ? localContext : new BasicHttpContext());
return context;
}
@Override @Override
protected CloseableHttpResponse doExecute( protected CloseableHttpResponse doExecute(
final HttpHost target, final HttpHost target,
@ -98,20 +92,16 @@ class MinimalHttpClient extends CloseableHttpClient {
} }
try { try {
HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(request); HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(request);
HttpClientContext localcontext = setupContext(context); HttpClientContext localcontext = HttpClientContext.adapt(
context != null ? context : new BasicHttpContext());
HttpRoute route = new HttpRoute(target); HttpRoute route = new HttpRoute(target);
RequestConfig config = null; RequestConfig config = null;
if (request instanceof Configurable) { if (request instanceof Configurable) {
config = ((Configurable) request).getConfig(); config = ((Configurable) request).getConfig();
} }
if (config == null) { if (config != null) {
config = RequestConfig.DEFAULT; localcontext.setRequestConfig(config);
} }
if (config.getProxy() != null) {
throw new ClientProtocolException("Minimal HttpClient does not support" +
" request execution via proxy");
}
localcontext.setRequestConfig(config);
return this.requestExecutor.execute(route, wrapper, localcontext, execAware); return this.requestExecutor.execute(route, wrapper, localcontext, execAware);
} catch (HttpException httpException) { } catch (HttpException httpException) {
throw new ClientProtocolException(httpException); throw new ClientProtocolException(httpException);