| | |
| | | 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); |
| | |
| | | } |
| | | return myNanoHttpServer; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Response serve(IHTTPSession session) { |
| | |
| | | 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)"); |
| | |
| | | //响应客户端 |
| | | 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; |
| | | } |
| | | } |