Does Apache HttpClient manage Integrated URL Authentication?

I don't see it in the docs, ok here:

Does HttpClientauthorization support HTTP (proactive or otherwise) with credentials in the URL string?

For example: http://foo:bar@hostname/Hello/World enter the username fooand password barfor authorization (in fact authentication, but only using the same nomenclature).

Basically:

HttpClient client = new HttpClient();
GetMethod get = new GetMethod("http://foo:bar@hostname/Hello/World");

against:.

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 did not feel joy.
Am I something wrong?

+3
source share

Source: https://habr.com/ru/post/1771389/


All Articles