From a583d00d2e629b72cae74864d67168ccb5f71daa Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 28 十二月 2023 21:46:24 +0800
Subject: [PATCH] 2023年12月28日21:46:15
---
app/src/main/java/com/hdl/photovoltaic/internet/HttpServer/MyNanoHttpServer.java | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 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..e85256e 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
@@ -45,6 +45,7 @@
return myNanoHttpServer;
}
+
@Override
public Response serve(IHTTPSession session) {
//TODO 瑙e喅瀹㈡埛绔姹傚弬鏁版惡甯︿腑鏂囷紝鍑虹幇涓枃涔辩爜闂
@@ -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)");
}
//鏍规嵁璇锋眰澶у皬鍒涘缓缂撳瓨鍖�
--
Gitblit v1.8.0