0
有人可以解釋的用戶憑據究竟如何傳遞到下面的代碼服務器...Java的HTTP基本Authenication解釋
URL urlObj = new URL("https://javaguy.com");
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "text/xml");
String userPassword = username + ":" + password;
byte[] authEncBytes = Base64.encodeBase64(userPassword.getBytes());
String authStringEnc = new String(authEncBytes);
conn.setRequestProperty("Authorization", "Basic " + authStringEnc);
難道是HTTP頭的一部分?只是好奇。
在此先感謝。