我想使用DownloadManager
从我的大学互联网上下载文件。该网站使用Www-Authenticate:Negotiate,NTLM。
我使用下面的代码登录但它只适用于基本身份验证,那么如何让它与NTLM一起运行?
DownloadManager manger = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
final String basicAuth = "Basic " + Base64.encodeToString(String.format("%s:%s","username","password").getBytes(), Base64.DEFAULT);
request.addRequestHeader("Authorization" , basicAuth);
request.setTitle("file.pdf");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setVisibleInDownloadsUi(true);
request.setDescription(String.format("Downloading %s", "file.pdf"));
request.setDestinationInExternalPublicDir("MyGucFiles", "file.pdf");
request.allowScanningByMediaScanner();
manger.enqueue(request);