多线程测试

This commit is contained in:
lushunming 2025-06-18 15:46:48 +08:00
parent ff2ecbeefc
commit ca1754e3f0
4 changed files with 9 additions and 4 deletions

View File

@ -82,19 +82,20 @@ public class ProxyVideo {
SpiderDebug.log("--proxyMultiThread: start ");
Map<String, String> newHeaders = new HashMap<>(headers);
newHeaders.put("range", "bytes=0-0");
newHeaders.put("Range", "bytes=0-0");
Object[] info = proxy(url, newHeaders);
int code = (int) info[0];
if (code != 206) {
return proxy(url, headers);
}
String contentRange = ((Map<String, String>) info[3]).get("Content-Range");
String contentRange = StringUtils.isAllBlank(((Map<String, String>) info[3]).get("Content-Range")) ? ((Map<String, String>) info[3]).get("content-range") : ((Map<String, String>) info[3]).get("Content-Range");
SpiderDebug.log("--contentRange:" + contentRange);
//文件总大小
String total = StringUtils.split(contentRange, "/")[1];
SpiderDebug.log("--文件总大小:" + total);
String range = headers.get("range");
String range = StringUtils.isAllBlank(headers.get("range")) ? headers.get("Range") : headers.get("range");
SpiderDebug.log("---proxyMultiThread,Range:" + range);
Map<String, String> rangeObj = parseRange(range);
//没有range,无需分割
@ -115,6 +116,7 @@ public class ProxyVideo {
Map<String, String> headerNew = new HashMap<>(headers);
headerNew.put("range", newRange);
headerNew.put("Range", newRange);
Future<Response> result = service.submit(() -> {
try {
@ -135,6 +137,7 @@ public class ProxyVideo {
response = future.get();
bytes = ArrayUtils.addAll(bytes, response.body().bytes());
SpiderDebug.log("---第" + i + "块下载完成" + ";Content-Range:" + response.headers().get("Content-Range"));
SpiderDebug.log("---第" + i + "块下载完成" + ";content-range:" + response.headers().get("content-range"));
}
service.shutdown();
@ -150,7 +153,9 @@ public class ProxyVideo {
}
respHeaders.put("Content-Length", String.valueOf(bytes.length));
respHeaders.put("content-length", String.valueOf(bytes.length));
respHeaders.put("Content-Range", String.format("bytes %s-%s/%s", partList.get(0)[0], partList.get(THREAD_NUM - 1)[1], total));
respHeaders.put("content-range", String.format("bytes %s-%s/%s", partList.get(0)[0], partList.get(THREAD_NUM - 1)[1], total));
SpiderDebug.log("++proxy res contentType:" + contentType);
// SpiderDebug.log("++proxy res body:" + response.body());
SpiderDebug.log("++proxy res respHeaders:" + Json.toJson(respHeaders));

Binary file not shown.

View File

@ -1 +1 @@
0c62b039f16a98ecdb8b6e8ace67d52a
a1595a0b27f113878d7f0688ffddb952

View File

@ -1,5 +1,5 @@
{
"spider": "https://ghproxy.net/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/multiThread/jar/custom_spider.jar;md5;0c62b039f16a98ecdb8b6e8ace67d52a",
"spider": "https://ghproxy.net/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/multiThread/jar/custom_spider.jar;md5;a1595a0b27f113878d7f0688ffddb952",
"lives": [
{
"name": "电视直播",