From 44ba605a4e850efa757020da5fb4cf02bdf6e3ab Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期一, 08 九月 2025 10:55:18 +0800
Subject: [PATCH] 2025年09月08日10:55:15
---
app/src/main/java/com/hdl/photovoltaic/internet/HttpServer/MyNanoHttpServer.java | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/internet/HttpServer/MyNanoHttpServer.java b/app/src/main/java/com/hdl/photovoltaic/internet/HttpServer/MyNanoHttpServer.java
index d215b1a..3cc1df8 100644
--- a/app/src/main/java/com/hdl/photovoltaic/internet/HttpServer/MyNanoHttpServer.java
+++ b/app/src/main/java/com/hdl/photovoltaic/internet/HttpServer/MyNanoHttpServer.java
@@ -25,7 +25,7 @@
public class MyNanoHttpServer extends NanoHTTPD {
//澹版槑鏈嶅姟绔� 绔彛
- public static final Integer HTTP_PORT = 49152;
+ public static Integer HTTP_PORT = 49152;// 46219;
public MyNanoHttpServer(String hostname, int port) {
super(hostname, port);
@@ -44,6 +44,7 @@
}
return myNanoHttpServer;
}
+
@Override
public Response serve(IHTTPSession session) {
@@ -78,30 +79,37 @@
//椹卞姩鍗囩骇鏂囦欢璺緞
String fileName = ((HTTPSession) session).getUri();
if (!TextUtils.isEmpty(fileName)) {
- if (fileName.contains(HdlFileLogic.getInstance().getDriveRootPath())) {
+ if (fileName.contains(HdlFileLogic.getInstance().getDriveRootPath())
+ || fileName.contains(HdlFileLogic.getInstance().getFirmwareRootPath())) {
String range = session.getHeaders().get("range");
if (TextUtils.isEmpty(range)) {
return newFixedLengthResponse("閿欒,澶撮儴娌℃湁range瀛楁(-500)");
}
- if (range.contains("=")) {
+ HdlLogLogic.print("http閫嗗彉鍣ㄨ姹�===璇锋眰澶у皬-->" + range, true);
+ if (!range.contains("=")) {
+ HdlLogLogic.print("閿欒,range鐨剉alue鏍煎紡涓嶅.(-501)", true);
return newFixedLengthResponse("閿欒,range鐨剉alue鏍煎紡涓嶅.(-501)");
}
String[] bytesAry = range.split("=");
if (bytesAry.length < 2) {
+ HdlLogLogic.print("閿欒,range鐨剉alue鏍煎紡涓嶅.(-502)", true);
return newFixedLengthResponse("閿欒,range鐨剉alue鏍煎紡涓嶅.(-502)");
}
String[] dataIndex = bytesAry[1].split("-");
if (dataIndex.length < 2) {
+ HdlLogLogic.print("閿欒,range鐨剉alue鏍煎紡涓嶅.(-503)", true);
return newFixedLengthResponse("閿欒,range鐨剉alue鏍煎紡涓嶅.(-503)");
}
int startIndex = Integer.parseInt(dataIndex[0]);
int endIndex = Integer.parseInt(dataIndex[1]);
if (endIndex + 1 - startIndex <= 0) {
+ HdlLogLogic.print("閿欒,璇锋眰澶у皬鏈夐棶棰�.(-504)", true);
return newFixedLengthResponse("閿欒,璇锋眰澶у皬鏈夐棶棰�.(-504)");
}
//璇诲彇鏈湴鏂囦欢瀛楄妭娴�
byte[] sourceDataByte = HdlFileLogic.getInstance().readFileByte(fileName);
if (sourceDataByte == null || sourceDataByte.length == 0) {
+ HdlLogLogic.print("閿欒,鏈湴鎵句笉鍒版枃浠�,璇蜂笅杞藉啀璇�.(-505)", true);
return newFixedLengthResponse("閿欒,鏈湴鎵句笉鍒版枃浠�,璇蜂笅杞藉啀璇�.(-505)");
}
//鏍规嵁璇锋眰澶у皬鍒涘缓缂撳瓨鍖�
@@ -111,7 +119,7 @@
//鍝嶅簲瀹㈡埛绔�
Response response = newFixedLengthResponse(newByte);
response.addHeader("Content-Range", range + "/" + sourceDataByte.length);//浼熷崡闇�瑕佽繖涓瓧娈�
- HdlLogLogic.print("http鍥炲鏁版嵁===璇锋眰澶у皬-->" + range + "=====鏂囦欢澶у皬-->" + sourceDataByte.length, true);
+ HdlLogLogic.print("http鍥炲鏁版嵁===璇锋眰澶у皬--" + range + "=====鏂囦欢澶у皬--" + sourceDataByte.length, true);
return response;
}
}
--
Gitblit v1.8.0