有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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) 个答案