Java 11 HttpClient not sending basic authentication
问题 I wrote the following HttpClient code, and it did not result in an Authorization header being sent to the server: public static void main(String[] args) { var client = HttpClient.newBuilder() .authenticator(new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("username", "password".toCharArray()); } }) .version(HttpClient.Version.HTTP_1_1) .build(); var request = HttpRequest.newBuilder() .uri("https://service-that