wjc
2025-03-19 949a7a45dd70e89531f121e9fcaee0d911f176e0
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) {
@@ -79,7 +80,7 @@
            String fileName = ((HTTPSession) session).getUri();
            if (!TextUtils.isEmpty(fileName)) {
                if (fileName.contains(HdlFileLogic.getInstance().getDriveRootPath())
                        ||fileName.contains(HdlFileLogic.getInstance().getFirmwareRootPath())) {
                        || fileName.contains(HdlFileLogic.getInstance().getFirmwareRootPath())) {
                    String range = session.getHeaders().get("range");
                    if (TextUtils.isEmpty(range)) {
                        return newFixedLengthResponse("错误,头部没有range字段(-500)");
@@ -118,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;
                }
            }