diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java index 26307a10c..79f388cb7 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java @@ -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) { diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java b/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java index f04393d8d..42a00e199 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java @@ -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());