我想使用DownloadManager從我的服務器解析與JSESSIONID的cookie的zip文件。我得到了這個JSESSIONID,使用HTTPCLIENT lib進行我所有的進程登錄,並設置一個變量JSESSIONID供以後在我的DownloadManager請求中使用。DownloadManager與Cookie身份驗證
我的下載請求:
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(htmlUrlDownload));
request.addRequestHeader("Cookie", "JSESSIONID=" + JSESSIONID);
request.addRequestHeader(Constants.USER_AGENT, Constants.TARGET_REQUEST_HEADER);
request.setDescription("Baixando " + metaDado.getType());
request.setTitle("Download");
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
String nameFile = offlineUuid + ".zip";
fileName = nameFile;
filePath = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_DOWNLOADS
+ File.separator + fileName;
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, nameFile);
final DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
final long downloadId = manager.enqueue(request);
的問題是,下載永遠不會啓動和COLUMN_REASON返回代碼ERROR_UNHANDLED_HTTP_CODE
但是,如果我嘗試使用Dropbox的鏈接來下載同一個文件,而無需身份驗證或使用httpclient,它是完美的,我做錯了什麼?
如何獲得更好的味精錯誤?
做ü檢查服務器日誌工作? – Akhil 2013-04-15 17:47:49
我無法訪問它。當我說我的服務器時,是我使用的服務器,是否明白? :( – 2013-04-16 13:51:24
反正重定向在下載管理器中不受支持,並且由於重定向,您的下載請求失敗。** [此鏈接可能對您有用](http://stackoverflow.com/a/13212978/1677824)** .. – Akhil 2013-04-16 15:47:25