[HTTPCLIENT-1221] Add DecompressingHttpClient 0-arg constructor using the DefaultHttpClient.

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1369841 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2012-08-06 13:32:35 +00:00
parent ceb7ebcc01
commit ccdebd9384
2 changed files with 20 additions and 12 deletions

View File

@ -73,10 +73,18 @@ import org.apache.http.util.EntityUtils;
*/
public class DecompressingHttpClient implements HttpClient {
private HttpClient backend;
private HttpRequestInterceptor acceptEncodingInterceptor;
private HttpResponseInterceptor contentEncodingInterceptor;
private final HttpClient backend;
private final HttpRequestInterceptor acceptEncodingInterceptor;
private final HttpResponseInterceptor contentEncodingInterceptor;
/**
* Constructs a decorator to ask for and handle compressed
* entities on the fly.
*/
public DecompressingHttpClient() {
this(new DefaultHttpClient());
}
/**
* Constructs a decorator to ask for and handle compressed
* entities on the fly.
@ -86,7 +94,7 @@ public class DecompressingHttpClient implements HttpClient {
public DecompressingHttpClient(HttpClient backend) {
this(backend, new RequestAcceptEncoding(), new ResponseContentEncoding());
}
DecompressingHttpClient(HttpClient backend,
HttpRequestInterceptor requestInterceptor,
HttpResponseInterceptor responseInterceptor) {

View File

@ -91,7 +91,7 @@ public class TestContentCodings extends ServerTestBase {
}
});
HttpClient client = new DecompressingHttpClient(new DefaultHttpClient());
HttpClient client = new DecompressingHttpClient();
HttpGet request = new HttpGet("/some-resource");
HttpResponse response = client.execute(getServerHttp(), request);
@ -114,7 +114,7 @@ public class TestContentCodings extends ServerTestBase {
this.localServer.register("*", createDeflateEncodingRequestHandler(entityText, false));
HttpClient client = new DecompressingHttpClient(new DefaultHttpClient());
HttpClient client = new DecompressingHttpClient();
HttpGet request = new HttpGet("/some-resource");
HttpResponse response = client.execute(getServerHttp(), request);
@ -137,7 +137,7 @@ public class TestContentCodings extends ServerTestBase {
this.localServer.register("*", createDeflateEncodingRequestHandler(entityText, true));
HttpClient client = new DecompressingHttpClient(new DefaultHttpClient());
HttpClient client = new DecompressingHttpClient();
HttpGet request = new HttpGet("/some-resource");
HttpResponse response = client.execute(getServerHttp(), request);
@ -158,7 +158,7 @@ public class TestContentCodings extends ServerTestBase {
this.localServer.register("*", createGzipEncodingRequestHandler(entityText));
HttpClient client = new DecompressingHttpClient(new DefaultHttpClient());
HttpClient client = new DecompressingHttpClient();
HttpGet request = new HttpGet("/some-resource");
HttpResponse response = client.execute(getServerHttp(), request);
@ -236,7 +236,7 @@ public class TestContentCodings extends ServerTestBase {
this.localServer.register("*", createGzipEncodingRequestHandler(entityText));
HttpClient client = new DecompressingHttpClient(new DefaultHttpClient());
HttpClient client = new DecompressingHttpClient();
HttpGet request = new HttpGet("/some-resource");
HttpResponse response = client.execute(getServerHttp(), request);
ByteArrayOutputStream out = new ByteArrayOutputStream();
@ -260,7 +260,7 @@ public class TestContentCodings extends ServerTestBase {
this.localServer.register("*", createDeflateEncodingRequestHandler(entityText, true));
HttpClient client = new DecompressingHttpClient(new DefaultHttpClient());
HttpClient client = new DecompressingHttpClient();
HttpGet request = new HttpGet("/some-resource");
HttpResponse response = client.execute(getServerHttp(), request);
@ -279,7 +279,7 @@ public class TestContentCodings extends ServerTestBase {
this.localServer.register("*", createGzipEncodingRequestHandler(entityText));
HttpClient client = new DecompressingHttpClient(new DefaultHttpClient());
HttpClient client = new DecompressingHttpClient();
HttpGet request = new HttpGet("/some-resource");
String response = client.execute(getServerHttp(), request, new BasicResponseHandler());
@ -294,7 +294,7 @@ public class TestContentCodings extends ServerTestBase {
this.localServer.register("*", createDeflateEncodingRequestHandler(entityText, false));
HttpClient client = new DecompressingHttpClient(new DefaultHttpClient());
HttpClient client = new DecompressingHttpClient();
HttpGet request = new HttpGet("/some-resource");
String response = client.execute(getServerHttp(), request, new BasicResponseHandler());