You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Jeprotea <je...@gmail.com> on 2010/01/15 06:41:50 UTC
httpclient4.0 Proxy Auth and Traget Host Auth
Hi,
Frist, I can pass through a proxy by a BasciAuthentication and connect
target host without Authentication request successfully, but for a target
host need a second
BasciAuthentication, i donn't know how to operate and set the second
BasciAuthentication params using httpclient4.0 API.
PS: I have read
http://hc.apache.org/httpcomponents-client/tutorial/html/authentication.html
,but
I have no idea to using it
....................
char[] passphrase = CommonParams.strPassPhase.toCharArray();
DefaultHttpClient httpclient =
CertUtils.getHttpClientWithCustomizedTrustManager(CommonParams.certsFile,
passphrase, CommonParams.host, CommonParams.portNumber);
if (httpclient == null)
return;
// make sure to use a proxy that make a connect
HttpHost proxy = new
HttpHost(CommonParams.proxyHost,CommonParams.proxyPortNumber);
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy);
HttpHost targetHost = new HttpHost(CommonParams.host,
CommonParams.portNumber, "https");
System.out.println("executing request: " +
aUriRequest.getRequestLine());
System.out.println("to target: " + targetHost);
HttpResponse response = httpclient.execute(targetHost, aUriRequest);
HttpEntity entity = response.getEntity();
.
.
.
Please help me! you'b better show me a special example ,thx~
Regards,
Jeprotea