java Apache的HttpClient管理内联URL身份验证吗?
我没有在文档中看到它,在这里检查很好:
是否HttpClient
使用URL行中的凭据管理HTTP授权(抢占式或其他)
例如:http://foo:bar@hostname/Hello/World
内联用户名foo
和密码bar
以进行授权(实际上是身份验证,但只是使用相同的术语)
基本上:
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);
我试过了,一点也不高兴。
我有什么问题吗
共 (0) 个答案