HttpClient では認証に失敗するが、ブラウザでは認証が成功する
-
19-09-2019 - |
質問
使っています HttpClient 4.0
リモート ホストから XML を取得します。のようなURLを使用すると、 https://user:pwd@www.somesite.com ブラウザでは正常に動作しますが、HttpClient ではこのスタックトレースで失敗します (次のように)。助言がありますか?使っています SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER
設定中 ThreadSafeClientConnManager
HTTPSリクエストを処理するため
コード(部分):
final HttpGet get= new HttpGet(url);
final HttpResponse response = this.client.execute(get);
return new BasicResponseHandler().handleResponse(response);
スタックトレース:
01-05 22:34:03.783: ERROR/SearchResults(11565):
Failed to process request to URL:
https://user:pwd@www.somesite.com/products/foo/meta/xml_proper_encoding.jsp?version=1
01-05 22:34:03.783: ERROR/SearchResults(11565):
org.apache.http.client.HttpResponseException: Unauthorized
解決
合格 UsernamePasswordCredentials
のように この例, 、URLにはありません。
所属していません StackOverflow