// File: /workspace/github_cpp_makefile_star2_O1/guoxuanhan[P]NetServer/httpsession.cpp
// Function: HttpSession::PraseHttpRequest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, _HttpRequestContext&)
bool HttpSession::PraseHttpRequest(std::string &msg, HttpRequestContext &httprequestcontext)
{
    //std::cout << "HttpServer::HttpParser" << std::endl;
    std::string crlf("\r\n"), crlfcrlf("\r\n\r\n");
    size_t prev = 0, next = 0, pos_colon;
    std::string key, value;

    bool praseresult = false;
    //以下解析可以改成状态机，解决一次收Http报文不完整问题
    //prase http request line
    if ((next = msg.find(crlf, prev)) != std::string::npos)
    {
        std::string first_line(msg.substr(prev, next - prev));
        prev = next;
        std::stringstream sstream(first_line);
        sstream >> (httprequestcontext.method);
        sstream >> (httprequestcontext.url);
        sstream >> (httprequestcontext.version);
    }
    else
    {
        std::cout << "msg" << msg << std::endl;
        std::cout << "Error in httpPraser: http_request_line isn't complete!" << std::endl;
        praseresult = false;
        msg.clear();
        return praseresult;
        //可以临时存起来，凑齐了再解析
    }
    //prase http request header
    size_t pos_crlfcrlf = 0;
    if (( pos_crlfcrlf = msg.find(crlfcrlf, prev)) != std::string::npos)
    {
        while (prev != pos_crlfcrlf)
        {
            next = msg.find(crlf, prev + 2);
            pos_colon = msg.find(":", prev + 2);
            key = msg.substr(prev + 2, pos_colon - prev-2);
            value = msg.substr(pos_colon + 2, next-pos_colon-2);
            prev = next;
            httprequestcontext.header.insert(std::pair<std::string, std::string>(key, value));
        }
    }
    else
    {
        std::cout << "Error in httpPraser: http_request_header isn't complete!" << std::endl;
        praseresult = false;
        msg.clear();
        return praseresult;
    }
    //prase http request body
    httprequestcontext.body = msg.substr(pos_crlfcrlf + 4);
    praseresult = true;
    msg.clear();
    return praseresult;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rdx, %rbp
movq %rsi, %rbx
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x7dfa(%rip), %rsi      # 0x10a59
leaq 0x7df5(%rip), %rdx      # 0x10a5b
leaq 0x20(%rsp), %rdi
callq 0x613c
leaq 0x60(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x7dd6(%rip), %rsi      # 0x10a57
leaq 0x7dd3(%rip), %rdx      # 0x10a5b
leaq 0x50(%rsp), %rdi
callq 0x613c
leaq 0x80(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0xa0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4590
cmpq $-0x1, %rax
movq %rbx, 0x8(%rsp)
je 0x8f4d
leaq 0xb0(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rbx
movq %rax, %rcx
callq 0x4360
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
movl $0x18, %edx
callq 0x4500
leaq 0xd0(%rsp), %rdi
movq %rbp, %rsi
callq 0x4420
leaq 0x20(%rbp), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x4420
leaq 0x40(%rbp), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x4420
movq 0xf252(%rip), %rsi      # 0x17f98
leaq 0xd0(%rsp), %rdi
callq 0x4290
leaq 0x150(%rsp), %rdi
callq 0x4110
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8d76
callq 0x4310
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rcx
movq 0x8(%rsp), %rdi
movq %rbx, %rdx
callq 0x4590
movq %rax, %r14
cmpq $-0x1, %rax
setne %al
je 0x8fef
movl %eax, 0x14(%rsp)
movq %rbp, 0x18(%rsp)
cmpq %r14, %rbx
je 0x8ee5
leaq 0xe0(%rsp), %r15
movq 0x18(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x40(%rsp)
movq %r14, 0x48(%rsp)
movq 0x8(%rsp), %rbp
movq %r15, %r14
leaq 0x2(%rbx), %r15
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rcx
movq %rbp, %rdi
movq %r15, %rdx
callq 0x4590
movq %rax, %r12
movl $0x1, %ecx
movq %rbp, %rdi
leaq 0x85e9(%rip), %rsi      # 0x113e6
movq %r15, %rdx
callq 0x4590
movq %rax, %r13
movq %rax, %rcx
subq %rbx, %rcx
leaq 0xd0(%rsp), %rbx
addq $-0x2, %rcx
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4360
leaq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x4400
movq 0xd0(%rsp), %rdi
movq %r14, %r15
cmpq %r14, %rdi
je 0x8e4a
callq 0x4310
movq %r12, %rcx
subq %r13, %rcx
addq $0x2, %r13
addq $-0x2, %rcx
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x4360
leaq 0x90(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4400
movq 0xd0(%rsp), %rdi
cmpq %r15, %rdi
movq 0x48(%rsp), %r14
je 0x8e90
callq 0x4310
movq %rbx, %rdi
leaq 0x70(%rsp), %rsi
movq %r13, %rdx
callq 0xa822
movq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0xaa14
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x8ec7
callq 0x4310
movq 0xd0(%rsp), %rdi
cmpq %r15, %rdi
je 0x8ed9
callq 0x4310
movq %r12, %rbx
cmpq %r14, %r12
jne 0x8dcf
addq $0x4, %r14
leaq 0xd0(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq $-0x1, %rcx
callq 0x4360
movq 0x18(%rsp), %rdi
addq $0x90, %rdi
leaq 0xd0(%rsp), %r14
movq %r14, %rsi
callq 0x4400
movq (%r14), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
leaq 0x30(%rsp), %r15
leaq 0x60(%rsp), %r12
movl 0x14(%rsp), %ebp
je 0x9037
callq 0x4310
jmp 0x9037
movq 0xf064(%rip), %rdi      # 0x17fb8
leaq 0x7b01(%rip), %rsi      # 0x10a5c
movl $0x3, %edx
callq 0x43a0
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0xf040(%rip), %rdi      # 0x17fb8
callq 0x43a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4320
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4240
movq 0xf00a(%rip), %r14      # 0x17fb8
leaq 0x7aab(%rip), %rsi      # 0x10a60
movl $0x36, %edx
movq %r14, %rdi
callq 0x43a0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4320
movsbl %al, %esi
movq 0xefd8(%rip), %rdi      # 0x17fb8
callq 0x4030
movq %rax, %rdi
callq 0x4240
jmp 0x9035
movq 0xefc2(%rip), %r14      # 0x17fb8
leaq 0x7a9a(%rip), %rsi      # 0x10a97
movl $0x38, %edx
movq %r14, %rdi
callq 0x43a0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4320
movsbl %al, %esi
movq 0xef90(%rip), %rdi      # 0x17fb8
callq 0x4030
movq %rax, %rdi
callq 0x4240
xorl %ebp, %ebp
movq 0x8(%rsp), %rax
movq $0x0, 0x8(%rax)
movq (%rax), %rax
movb $0x0, (%rax)
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x9064
callq 0x4310
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x907b
callq 0x4310
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x908a
callq 0x4310
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x9099
callq 0x4310
movl %ebp, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9102
movq %rax, %rbx
jmp 0x90e4
jmp 0x9102
jmp 0x9102
movq %rax, %rbx
jmp 0x915c
movq %rax, %rbx
movq 0xeece(%rip), %rsi      # 0x17f98
leaq 0xd0(%rsp), %rdi
callq 0x4290
leaq 0x150(%rsp), %rdi
callq 0x4110
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9117
callq 0x4310
jmp 0x9117
jmp 0x9102
jmp 0x9102
jmp 0x9102
movq %rax, %rbx
jmp 0x9117
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0xa880
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x9131
callq 0x4310
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x9148
callq 0x4310
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x915c
callq 0x4310
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x9170
callq 0x4310
movq %rbx, %rdi
callq 0x45a0