Does Apache's HttpClient manage inlined URL authentication?
I'm not seeing it in docs, good to check here:
Does HttpClient
manage HTTP authorization (preemptive or otherwise) with credentials in the URL line?
For instance: http://foo:bar@hostname/Hello/World
inlines username foo
and password bar
for 开发者_如何学Cauthorization (actually authentication, but just using same nomenclature).
Basically:
HttpClient client = new HttpClient();
GetMethod get = new GetMethod("http://foo:bar@hostname/Hello/World");
vs.:
HttpClient client = new HttpClient();
client.getState().setCredentials(
new AuthScope( /* stuff */ );
, new UsernamePasswordCredentials("foo","bar");
);
GetMethod get = new GetMethod("http://foo:bar@hostname/Hello/World");
get.setDoAuthentication(true);
I tried it no joy.
Am I something wrong?
精彩评论