public org.apache.http.client.HttpClient configureClient() { HttpParams params = configureHttpParams(); ClientConnectionManager connectionManager = configureConnectionManager(params); DefaultHttpClient client = new DefaultHttpClient(connectionManager, params); if (username != null && password != null) { client.getCredentialsProvider().setCredentials( new AuthScope(host, port, AuthScope.ANY_REALM), new UsernamePasswordCredentials(username, password)); client.addRequestInterceptor( new PreemptiveAuthRequestInterceptor(), 0); } if (compression) { return new DecompressingHttpClient(client); } return client; }