On Mon, 2012-10-01 at 10:49 -0400, Gary Gregory wrote: > Hi All: > > I have 4.2.1 client code like this: > > private DefaultHttpClient httpClient; > ... > this.httpClient = new *ContentEncodingHttpClient*(new > PoolingClientConnectionManager(this.schemeRegistry), params); > > According to the Javadoc I should use a DecompressingHttpClient instead, so > I code: > > this.httpClient = new DecompressingHttpClient(new > DecompressingHttpClient (new > PoolingClientConnectionManager(this.schemeRegistry), params)); > > Which means I have to retype DefaultHttpClient as a DecompressingHttpClient. > > I do not use the HttpClient interface because I need to call > org.apache.http.impl.client.AbstractHttpClient.getCredentialsProvider() > > But there is no way to get from a DecompressingHttpClient (which implements > HttpClient) to its DefaultHttpClient so I can call getCredentialsProvider(). > > In order to do what I need would need to save both DecompressingHttpClient > and its DecompressingHttpClient in ivars which smells wrong to me. > > Option 1: > > Add "public HttpClient getBackend()" to DecompressingHttpClient, which I > can call and cast to a DefaultHttpClient. > > Option 2: >
You can always override CredentialsProvider set at the client level by setting a different one in the local HttpContext instance --- CredentialsProvider credsProvider = new BasicCredentialsProvider(); HttpContext localContext = new BasicHttpContext(); localContext.setAttribute(ClientContext.CREDS_PROVIDER, credsProvider); HttpResponse response = httpclient.execute(httpget, localContext); --- Besides, this should work as well private CredentialsProvider credsProvider; private HttpClient httpClient; --- this.credsProvider = new BasicCredentialsProvider(); DefaultHttpClient dc = new DefaultHttpClient(); dc.setCredentialsProvier(this.credsProvider); this.httpClient = new DecompressingHttpClient(dc); --- Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
