POST 支持

pull/330/head
AriaLyy 7 years ago
parent 1d7f59c0a5
commit 3773e254d8
  1. 13
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java
  2. 1
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java
  3. 3
      Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java
  4. 6
      Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java
  5. 2
      Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java
  6. 2
      DEV_LOG.md
  7. 6
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java

@ -17,7 +17,6 @@ package com.arialyy.aria.core.download;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.inf.AbsDownloadTarget; import com.arialyy.aria.core.inf.AbsDownloadTarget;
import com.arialyy.aria.core.manager.TEManager; import com.arialyy.aria.core.manager.TEManager;
import com.arialyy.aria.core.queue.DownloadTaskQueue; import com.arialyy.aria.core.queue.DownloadTaskQueue;
@ -63,6 +62,18 @@ public class DownloadTarget
mTaskEntity.refreshInfo = refreshInfo; 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在下载队列中有且只有一个最高优先级任务 * 1在下载队列中有且只有一个最高优先级任务

@ -54,6 +54,7 @@ class HttpFileInfoThread implements Runnable {
conn = ConnectionHelp.setConnectParam(mTaskEntity, conn); conn = ConnectionHelp.setConnectParam(mTaskEntity, conn);
conn.setRequestProperty("Range", "bytes=" + 0 + "-"); conn.setRequestProperty("Range", "bytes=" + 0 + "-");
conn.setConnectTimeout(mConnectTimeOut); conn.setConnectTimeout(mConnectTimeOut);
conn.setRequestMethod(mTaskEntity.requestEnum.name);
conn.connect(); conn.connect();
handleConnect(conn); handleConnect(conn);
} catch (IOException e) { } catch (IOException e) {

@ -154,7 +154,8 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti
} }
/** /**
* 设置请求类型 * 设置请求类型POST或GET默认为在GET
* 只试用于HTTP请求
* *
* @param requestEnum {@link RequestEnum} * @param requestEnum {@link RequestEnum}
*/ */

@ -105,6 +105,12 @@ public abstract class AbsTaskEntity<ENTITY extends AbsEntity> extends DbEntity {
*/ */
public String md5Key = "Content-MD5"; public String md5Key = "Content-MD5";
/**
* 是否使用服务器通过content-disposition传递的文件名内容格式{@code attachment;filename=***}
* {@code true} 使用
*/
public boolean useServerFileName = false;
/** /**
* 从header中获取文件描述信息所需要的key * 从header中获取文件描述信息所需要的key
*/ */

@ -35,7 +35,7 @@ class DBConfig {
static Map<String, Class> mapping = new HashMap<>(); static Map<String, Class> mapping = new HashMap<>();
static String DB_NAME; static String DB_NAME;
//static int VERSION = 16; //static int VERSION = 16;
static int VERSION = 17; static int VERSION = 18;
static { static {
if (TextUtils.isEmpty(DB_NAME)) { if (TextUtils.isEmpty(DB_NAME)) {

@ -1,4 +1,6 @@
## 开发日志 ## 开发日志
+ v_3.3.8
- 添加POST支持
+ v_3.3.7 + v_3.3.7
- 修复一个线程重启的问题 https://github.com/AriaLyy/Aria/issues/160 - 修复一个线程重启的问题 https://github.com/AriaLyy/Aria/issues/160
- 修复配置文件异常问题、格式化速度为0问题 https://github.com/AriaLyy/Aria/issues/161 - 修复配置文件异常问题、格式化速度为0问题 https://github.com/AriaLyy/Aria/issues/161

@ -29,6 +29,7 @@ import butterknife.Bind;
import com.arialyy.annotations.Download; import com.arialyy.annotations.Download;
import com.arialyy.annotations.DownloadGroup; import com.arialyy.annotations.DownloadGroup;
import com.arialyy.aria.core.Aria; 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.DownloadEntity;
import com.arialyy.aria.core.download.DownloadGroupTask; import com.arialyy.aria.core.download.DownloadGroupTask;
import com.arialyy.aria.core.download.DownloadTarget; import com.arialyy.aria.core.download.DownloadTarget;
@ -60,8 +61,8 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
//"http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-"; //"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://172.18.104.50:8080/download/_302turn";
//"http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk"; //"http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk";
"http://shouji.360tpcdn.com/160824/2c0407dbab4a86c7a84fa7340b9969e7/block.app.wars_30.apk"; //"http://shouji.360tpcdn.com/160824/2c0407dbab4a86c7a84fa7340b9969e7/block.app.wars_30.apk";
//"http://172.21.1.99:8080/download/test+ 中文123.zip"; "http://172.21.1.72:8080/download/test+ 中文123.zip";
@Bind(R.id.start) Button mStart; @Bind(R.id.start) Button mStart;
@Bind(R.id.stop) Button mStop; @Bind(R.id.stop) Button mStop;
@Bind(R.id.cancel) Button mCancel; @Bind(R.id.cancel) Button mCancel;
@ -228,6 +229,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
Aria.download(SingleTaskActivity.this) Aria.download(SingleTaskActivity.this)
.load(DOWNLOAD_URL) .load(DOWNLOAD_URL)
.addHeader("groupName", "value") .addHeader("groupName", "value")
.setRequestMode(RequestEnum.POST)
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk") .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk")
.start(); .start();
} }

Loading…
Cancel
Save