HTTP リクエストの認証ヘッダーを読み取ろうとしています (何かを追加する必要があるため) が、ヘッダー値が常に null になります。他のヘッダーは問題なく動作します。
public void testAuth() throws MalformedURLException, IOException{
URLConnection request = new URL("http://google.com").openConnection();
request.setRequestProperty("Authorization", "MyHeader");
request.setRequestProperty("Stackoverflow", "anotherHeader");
// works fine
assertEquals("anotherHeader", request.getRequestProperty("Stackoverflow"));
// Auth header returns null
assertEquals("MyHeader", request.getRequestProperty("Authorization"));
}
私は何か間違ったことをしていますか?これは「セキュリティ」機能ですか?これを URLConnection で機能させる方法はありますか、それとも別の HTTP クライアント ライブラリを使用する必要がありますか?