// File: /workspace/github_cpp_makefile_star2_O2/MisakiFx[P]P2PDownload/./server.hpp
// Function: P2PServer::GetFileData(httplib::Request const&, httplib::Response&)
static void GetFileData(const Request& req, Response& rsp)
  {
    bf::path path(req.path);
    std::string name = std::string(SHARE_PATH) + "/" + path.filename().string();
    if(!bf::exists(name))
    {
      rsp.status = 404;
      return;
    }
    if(bf::is_directory(name))
    {
      rsp.status = 403;
      return;
    }
    //条件符合正式开始传输文件
    //获取文件大小
    int64_t fsize = bf::file_size(name);
    //如果发送的是HEAD请求，客户端此时只想要文件长度，则只用包装头部即可
    if(req.method == "HEAD")
    {
      rsp.status = 200;
      std::string len = std::to_string(fsize);
      rsp.set_header("Content-Length", len.c_str());
      return;
    }
    //GET方法，开始分块传输
    else
    {
      //没有Range信息则直接报错
      if(!req.has_header("Range"))
      {
        rsp.status = 400;
        return;
      }
      std::string range_val = req.get_header_value("Range");
      int64_t start, end, rlen;
      //开始解析range_val:bytes=start-end
      bool ret = RangeParse(range_val, start, rlen);
      if(ret == false)
      {
        rsp.status = 400;
        return;
      }
      //打开文件
      std::ifstream file(name, std::ios::binary);
      if(!file.is_open())
      {
        std::cerr << "file open failed!" << std::endl;
        rsp.status = 404;
        return;
      }
      file.seekg(start, std::ios::beg);
      rsp.body.resize(rlen);
      //读取数据到bdoy中
      file.read(&rsp.body[0], rlen);
      if(!file.good())
      {
        std::cerr << "read file" << name << " body error" << std::endl;
        rsp.status = 500;
        return;
      }
      file.close();
      //内容类型设置为二进制流
      rsp.set_header("Content-Type", "application/octet-stream");
      rsp.status = 206;
      std::cout << "file range " << range_val << " download success" << std::endl;
    }
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x60(%rdi), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x87b0
leaq 0x1a583(%rip), %rsi     # 0x241b2
leaq -0x40(%rbp), %rdi
leaq -0x20(%rbp), %rdx
callq 0x81d0
leaq 0x1b19c(%rip), %rdx     # 0x24ddf
leaq -0x2a8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x14719
leaq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x8490
leaq -0x60(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x146f0
leaq -0x80(%rbp), %rdi
callq 0x8aa8
leaq -0x2a8(%rbp), %rdi
callq 0x8aa8
leaq -0x40(%rbp), %rdi
callq 0x8aa8
leaq -0x2a8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x87b0
leaq -0x2a8(%rbp), %rdi
callq 0x99a8
movl %eax, %r15d
leaq -0x2a8(%rbp), %rdi
callq 0x8aa8
testb %r15b, %r15b
je 0x9d01
leaq -0x2a8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x87b0
leaq -0x2a8(%rbp), %rdi
callq 0x14742
movl %eax, %r15d
leaq -0x2a8(%rbp), %rdi
callq 0x8aa8
testb %r15b, %r15b
je 0x9d0d
movl $0x193, 0x20(%rbx)      # imm = 0x193
jmp 0x9ecc
movl $0x194, 0x20(%rbx)      # imm = 0x194
jmp 0x9ecc
leaq -0x2a8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x87b0
leaq -0x2a8(%rbp), %rdi
callq 0x14766
movq %rax, %r15
leaq -0x2a8(%rbp), %rdi
callq 0x8aa8
leaq 0x20(%r14), %rdi
leaq 0x1af22(%rip), %rsi     # 0x24c65
callq 0xe8a4
testb %al, %al
je 0x9d84
movl $0xc8, 0x20(%rbx)
leaq -0x2a8(%rbp), %rdi
movq %r15, %rsi
callq 0x14772
movq -0x2a8(%rbp), %rdx
leaq 0x1aefa(%rip), %rsi     # 0x24c6a
movq %rbx, %rdi
callq 0x1424e
leaq -0x2a8(%rbp), %rdi
jmp 0x9ec7
leaq 0x80(%r14), %rdi
leaq 0x1aee7(%rip), %rsi     # 0x24c79
callq 0x14aa1
testb %al, %al
je 0x9e80
leaq 0x1aed3(%rip), %rdx     # 0x24c79
leaq -0x40(%rbp), %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x147d2
leaq -0x40(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x14810
testb %al, %al
je 0x9e89
leaq -0x2a8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
pushq $0x4
popq %rdx
callq 0x88e0
leaq -0x230(%rbp), %rdi
callq 0x80e0
testb %al, %al
je 0x9e92
movq -0x80(%rbp), %rsi
leaq -0x2a8(%rbp), %rdi
xorl %edx, %edx
callq 0x8790
leaq 0x58(%rbx), %r14
movq -0x20(%rbp), %rsi
movq %r14, %rdi
callq 0x87c0
movq (%r14), %rsi
movq -0x20(%rbp), %rdx
leaq -0x2a8(%rbp), %rdi
callq 0x86e0
movq -0x2a8(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x288(%rbp,%rax)
je 0x9eef
movq 0x2e19f(%rip), %rdi     # 0x37fe8
leaq 0x1ae41(%rip), %rsi     # 0x24c91
callq 0x8530
leaq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x84b0
leaq 0x1ae33(%rip), %rsi     # 0x24c9b
movq %rax, %rdi
callq 0x8530
movl $0x1f4, %r14d           # imm = 0x1F4
movq %rax, %rdi
callq 0x8250
jmp 0x9eb3
movl $0x190, 0x20(%rbx)      # imm = 0x190
jmp 0x9ecc
movl $0x190, 0x20(%rbx)      # imm = 0x190
jmp 0x9ec3
movq 0x2e14f(%rip), %rdi     # 0x37fe8
leaq 0x1addf(%rip), %rsi     # 0x24c7f
callq 0x8530
movl $0x194, %r14d           # imm = 0x194
movq %rax, %rdi
callq 0x8250
movl %r14d, 0x20(%rbx)
leaq -0x2a8(%rbp), %rdi
callq 0x8100
leaq -0x40(%rbp), %rdi
callq 0x8aa8
leaq -0x60(%rbp), %rdi
callq 0x8aa8
leaq -0xa0(%rbp), %rdi
callq 0x8aa8
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq -0x2a8(%rbp), %rdi
callq 0x80c0
leaq 0x1ab85(%rip), %rsi     # 0x24a87
leaq 0x1ad9e(%rip), %rdx     # 0x24ca7
movq %rbx, %rdi
callq 0x1424e
movl $0xce, 0x20(%rbx)
movq 0x2e079(%rip), %rdi     # 0x37f98
leaq 0x1ad9a(%rip), %rsi     # 0x24cc0
callq 0x8530
leaq -0x40(%rbp), %rsi
movq %rax, %rdi
callq 0x84b0
leaq 0x1ad8e(%rip), %rsi     # 0x24ccc
movq %rax, %rdi
callq 0x8530
movq %rax, %rdi
callq 0x8250
jmp 0x9eb7
jmp 0x9f55
movq %rax, %rbx
jmp 0x9f71
jmp 0x9f90
jmp 0x9f7f
jmp 0x9f90
jmp 0x9f90
movq %rax, %rbx
leaq -0x2a8(%rbp), %rdi
callq 0x8100
leaq -0x40(%rbp), %rdi
jmp 0x9f89
jmp 0x9f7f
jmp 0x9f90
jmp 0x9f7f
jmp 0x9f90
movq %rax, %rbx
leaq -0x2a8(%rbp), %rdi
callq 0x8aa8
jmp 0x9f93
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
jmp 0x9fbf
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x8aa8
jmp 0x9faa
movq %rax, %rbx
leaq -0x2a8(%rbp), %rdi
callq 0x8aa8
jmp 0x9fbb
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x8aa8
leaq -0xa0(%rbp), %rdi
callq 0x8aa8
movq %rbx, %rdi
callq 0x8990
movq %rax, %rbx
jmp 0x9fc4
nop