现在http文件下载将使用HEAD请求获取文件大小,配置文件增加 <useHeadRequest value=false/>

This commit is contained in:
laoyuyu
2020-07-27 20:21:15 +08:00
parent 9d8bf579b6
commit 5f60b9ed57
9 changed files with 49 additions and 24 deletions

View File

@@ -15,6 +15,7 @@
*/
package com.arialyy.aria.core.config;
import com.arialyy.aria.core.AriaConfig;
import com.arialyy.aria.core.event.DGMaxNumEvent;
import com.arialyy.aria.core.event.DSpeedEvent;
import com.arialyy.aria.core.event.EventMsgUtil;
@@ -63,22 +64,7 @@ public class DGroupConfig extends BaseTaskConfig implements Serializable {
}
public DownloadConfig getSubConfig() {
if (subConfig == null) {
subConfig = new DownloadConfig();
subConfig.threadNum = 1;
subConfig.useBlock = false;
subConfig.buffSize = buffSize;
subConfig.caName = caName;
subConfig.caPath = caPath;
subConfig.connectTimeOut = connectTimeOut;
subConfig.iOTimeOut = iOTimeOut;
subConfig.isConvertSpeed = isConvertSpeed;
subConfig.maxSpeed = maxSpeed;
subConfig.queueMod = "now";
subConfig.reTryInterval = subReTryInterval;
subConfig.reTryNum = subReTryNum;
subConfig.updateInterval = updateInterval;
}
subConfig = AriaConfig.getInstance().getDConfig();
return subConfig;
}

View File

@@ -44,6 +44,21 @@ public class DownloadConfig extends BaseTaskConfig implements Serializable {
*/
boolean useBlock = true;
/**
* 设置http下载获取文件大小是否使用Head请求。true使用head请求false使用默认的get请求
*/
boolean useHeadRequest;
public boolean isUseHeadRequest() {
return useHeadRequest;
}
public DownloadConfig setUseHeadRequest(boolean useHeadRequest) {
this.useHeadRequest = useHeadRequest;
save();
return this;
}
public boolean isUseBlock() {
return useBlock;
}

View File

@@ -146,7 +146,7 @@ public class XMLReader extends DefaultHandler {
break;
case "subFailAsStop": // 子任务失败时回调stop
setField("subFailAsStop", checkBoolean(value) ? Boolean.valueOf(value) : false,
ConfigType.D_GROUP);
ConfigType.D_GROUP);
break;
case "subReTryNum": // 子任务重试次数
int subReTryNum = checkInt(value) ? Integer.parseInt(value) : 5;
@@ -156,6 +156,10 @@ public class XMLReader extends DefaultHandler {
int subReTryInterval = checkInt(value) ? Integer.parseInt(value) : 2000;
setField("subReTryInterval", subReTryInterval, ConfigType.D_GROUP);
break;
case "useHeadRequest": // 是否使用head请求
boolean useHeadRequest = checkBoolean(value) ? Boolean.valueOf(value) : true;
setField("useHeadRequest", useHeadRequest, ConfigType.DOWNLOAD);
break;
}
} else if (mType == ConfigType.APP) {
String value = attributes.getValue("value");