From 3773e254d8a232a3f81caa26b156383c73f03678 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Thu, 30 Nov 2017 20:42:09 +0800 Subject: [PATCH] =?UTF-8?q?POST=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arialyy/aria/core/download/DownloadTarget.java | 13 ++++++++++++- .../download/downloader/HttpFileInfoThread.java | 1 + .../java/com/arialyy/aria/core/inf/AbsTarget.java | 3 ++- .../com/arialyy/aria/core/inf/AbsTaskEntity.java | 6 ++++++ .../main/java/com/arialyy/aria/orm/DBConfig.java | 2 +- DEV_LOG.md | 2 ++ .../arialyy/simple/download/SingleTaskActivity.java | 6 ++++-- 7 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java index b242af47..6c9cdeab 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java @@ -17,7 +17,6 @@ package com.arialyy.aria.core.download; import android.support.annotation.NonNull; import android.text.TextUtils; -import android.util.Log; import com.arialyy.aria.core.inf.AbsDownloadTarget; import com.arialyy.aria.core.manager.TEManager; import com.arialyy.aria.core.queue.DownloadTaskQueue; @@ -63,6 +62,18 @@ public class DownloadTarget mTaskEntity.refreshInfo = refreshInfo; } + /** + * 是否使用服务器通过content-disposition传递的文件名,内容格式{@code attachment;filename=***} + * 如果获取不到服务器文件名,则使用用户设置的文件名 + * 只适用于HTTP请求 + * + * @param use {@code true} 使用 + */ + @Deprecated public DownloadTarget useServerFileName(boolean use) { + mTaskEntity.useServerFileName = use; + return this; + } + /** * 将任务设置为最高优先级任务,最高优先级任务有以下特点: * 1、在下载队列中,有且只有一个最高优先级任务 diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java index 652696d1..64aa80ca 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java @@ -54,6 +54,7 @@ class HttpFileInfoThread implements Runnable { conn = ConnectionHelp.setConnectParam(mTaskEntity, conn); conn.setRequestProperty("Range", "bytes=" + 0 + "-"); conn.setConnectTimeout(mConnectTimeOut); + conn.setRequestMethod(mTaskEntity.requestEnum.name); conn.connect(); handleConnect(conn); } catch (IOException e) { diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java index aea773c3..cd922c51 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java @@ -154,7 +154,8 @@ public abstract class AbsTarget extends DbEntity { */ public String md5Key = "Content-MD5"; + /** + * 是否使用服务器通过content-disposition传递的文件名,内容格式{@code attachment;filename=***} + * {@code true} 使用 + */ + public boolean useServerFileName = false; + /** * 从header中获取文件描述信息所需要的key */ diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java index c5f44524..748f063d 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java @@ -35,7 +35,7 @@ class DBConfig { static Map mapping = new HashMap<>(); static String DB_NAME; //static int VERSION = 16; - static int VERSION = 17; + static int VERSION = 18; static { if (TextUtils.isEmpty(DB_NAME)) { diff --git a/DEV_LOG.md b/DEV_LOG.md index 48d2342f..b088dc4f 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,4 +1,6 @@ ## 开发日志 + + v_3.3.8 + - 添加POST支持 + v_3.3.7 - 修复一个线程重启的问题 https://github.com/AriaLyy/Aria/issues/160 - 修复配置文件异常问题、格式化速度为0问题 https://github.com/AriaLyy/Aria/issues/161 diff --git a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index 1c12838f..3c81ee05 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -29,6 +29,7 @@ import butterknife.Bind; import com.arialyy.annotations.Download; import com.arialyy.annotations.DownloadGroup; import com.arialyy.aria.core.Aria; +import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadGroupTask; import com.arialyy.aria.core.download.DownloadTarget; @@ -60,8 +61,8 @@ public class SingleTaskActivity extends BaseActivity { //"http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-"; //"http://172.18.104.50:8080/download/_302turn"; //"http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk"; - "http://shouji.360tpcdn.com/160824/2c0407dbab4a86c7a84fa7340b9969e7/block.app.wars_30.apk"; - //"http://172.21.1.99:8080/download/test+ 中文123.zip"; + //"http://shouji.360tpcdn.com/160824/2c0407dbab4a86c7a84fa7340b9969e7/block.app.wars_30.apk"; + "http://172.21.1.72:8080/download/test+ 中文123.zip"; @Bind(R.id.start) Button mStart; @Bind(R.id.stop) Button mStop; @Bind(R.id.cancel) Button mCancel; @@ -228,6 +229,7 @@ public class SingleTaskActivity extends BaseActivity { Aria.download(SingleTaskActivity.this) .load(DOWNLOAD_URL) .addHeader("groupName", "value") + .setRequestMode(RequestEnum.POST) .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk") .start(); }