// File: jixinqi[P]lazurite/./src/lazurite_core/http_request.cpp
// Function: lazurite::http::request_parser::parser_header()
bool lazurite::http::request_parser::parser_header()
{
    const std::size_t index = _request.raw_msg().find("\r\n\r\n");
    if (index == _request.raw_msg().npos)
    {
        return (_request.raw_msg().length() + 4 - _request.first_line_end_index() <= http_msg_header_max_length);
    }
    else if (index + 4 - _request.first_line_end_index() > http_msg_header_max_length)
    {
        return false;
    }

    std::size_t last_line_break_index = 0;
    std::size_t line_break_index = 0;
    std::string line;
    std::string key;
    std::string value;

    std::string raw_request_header = _request.raw_msg().substr
    (
        _request.first_line_end_index(),
        index - _request.first_line_end_index() + 2
    );

    while (line_break_index != raw_request_header.npos && line_break_index < raw_request_header.length())
    {
        last_line_break_index = line_break_index;
        line_break_index = raw_request_header.find("\r\n", line_break_index);
        line = raw_request_header.substr(last_line_break_index, line_break_index - last_line_break_index);
        line_break_index += 2;

        std::size_t colon_index = line.find(":");
        if (colon_index == line.npos)
        {
            return false;
        }

        key = line.substr(0, colon_index);
        value = line.substr(colon_index + 1, line.length() - 1);
        for (std::size_t erase_space_index = 0; erase_space_index != value.length(); erase_space_index++)
        {
            if (value.at(erase_space_index) != ' ')
            {
                value.erase(0, erase_space_index);
                break;
            }
        }

        _request.add_header(key, value);
    }
    _request.header_end_index(index + 4);

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0x1c0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x25b10
leaq -0x38(%rbp), %rdi
leaq 0x5fcb(%rip), %rsi      # 0x2c279
xorl %eax, %eax
movl %eax, %edx
callq 0x6780
movq %rax, -0x1c8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x67a8
movq -0x1c8(%rbp), %rax
movq -0x1c0(%rbp), %rsi
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x1b8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x25b10
leaq -0x58(%rbp), %rdi
callq 0x67a8
movq -0x1b8(%rbp), %rax
cmpq $-0x1, %rax
jne 0x2635c
movq -0x1c0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x25b10
leaq -0x78(%rbp), %rdi
callq 0x65d0
movq -0x1c0(%rbp), %rdi
addq $0x4, %rax
movq %rax, -0x1d0(%rbp)
callq 0x25cb0
movq %rax, %rcx
movq -0x1d0(%rbp), %rax
subq %rcx, %rax
cmpq $0x4000, %rax           # imm = 0x4000
setbe %al
andb $0x1, %al
movb %al, -0x1(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x67a8
jmp 0x2678c
movq -0x1c0(%rbp), %rdi
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x1d8(%rbp)
callq 0x25cb0
movq %rax, %rcx
movq -0x1d8(%rbp), %rax
subq %rcx, %rax
cmpq $0x4000, %rax           # imm = 0x4000
jbe 0x26395
movb $0x0, -0x1(%rbp)
jmp 0x2678c
jmp 0x26397
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x6570
leaq -0xc8(%rbp), %rdi
callq 0x6570
leaq -0xe8(%rbp), %rdi
callq 0x6570
movq -0x1c0(%rbp), %rsi
leaq -0x128(%rbp), %rdi
callq 0x25b10
jmp 0x263e3
movq -0x1c0(%rbp), %rdi
callq 0x25cb0
movq -0x1c0(%rbp), %rdi
movq %rax, -0x1e0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x1e8(%rbp)
callq 0x25cb0
movq -0x1e8(%rbp), %rcx
movq -0x1e0(%rbp), %rdx
subq %rax, %rcx
addq $0x2, %rcx
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x6400
jmp 0x26437
leaq -0x128(%rbp), %rdi
callq 0x67a8
xorl %eax, %eax
cmpq $-0x1, -0x88(%rbp)
movb %al, -0x1e9(%rbp)
je 0x26485
movq -0x88(%rbp), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x65d0
movq %rax, %rcx
movq -0x1f8(%rbp), %rax
cmpq %rcx, %rax
setb %al
movb %al, -0x1e9(%rbp)
movb -0x1e9(%rbp), %al
testb $0x1, %al
jne 0x26494
jmp 0x26712
movq -0x88(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x88(%rbp), %rdx
leaq 0x5dce(%rip), %rsi      # 0x2c27b
leaq -0x108(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x6780
movq -0x200(%rbp), %rsi
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdx
movq -0x88(%rbp), %rcx
subq %rdx, %rcx
leaq -0x158(%rbp), %rdi
callq 0x6400
jmp 0x264ea
leaq -0xa8(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x64a0
leaq -0x158(%rbp), %rdi
callq 0x67a8
movq -0x88(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x88(%rbp)
leaq -0xa8(%rbp), %rdi
leaq 0x5d55(%rip), %rsi      # 0x2c27e
xorl %eax, %eax
movl %eax, %edx
callq 0x6780
movq %rax, -0x160(%rbp)
cmpq $-0x1, -0x160(%rbp)
jne 0x265b3
movb $0x0, -0x1(%rbp)
movl $0x1, -0x164(%rbp)
jmp 0x26734
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x26766
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x67a8
jmp 0x26766
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x67a8
jmp 0x26766
movq -0x160(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x188(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x6400
jmp 0x265d3
leaq -0xc8(%rbp), %rdi
leaq -0x188(%rbp), %rsi
movq %rsi, -0x218(%rbp)
callq 0x64a0
movq -0x218(%rbp), %rdi
callq 0x67a8
movq -0x160(%rbp), %rax
incq %rax
movq %rax, -0x208(%rbp)
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x65d0
movq -0x210(%rbp), %rsi
movq -0x208(%rbp), %rdx
movq %rax, %rcx
decq %rcx
leaq -0x1a8(%rbp), %rdi
callq 0x6400
jmp 0x2663f
leaq -0xe8(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x64a0
leaq -0x1a8(%rbp), %rdi
callq 0x67a8
movq $0x0, -0x1b0(%rbp)
movq -0x1b0(%rbp), %rax
movq %rax, -0x220(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x65d0
movq %rax, %rcx
movq -0x220(%rbp), %rax
cmpq %rcx, %rax
je 0x266f1
movq -0x1b0(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0x6740
movq %rax, -0x228(%rbp)
jmp 0x266ae
movq -0x228(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
je 0x266d8
movq -0x1b0(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
leaq -0xe8(%rbp), %rdi
callq 0x60e0
jmp 0x266d6
jmp 0x266f1
jmp 0x266da
movq -0x1b0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1b0(%rbp)
jmp 0x26669
movq -0x1c0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
callq 0x259e0
jmp 0x2670d
jmp 0x26443
movq -0x1c0(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x4, %rsi
callq 0x25c70
movb $0x1, -0x1(%rbp)
movl $0x1, -0x164(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x67a8
leaq -0xe8(%rbp), %rdi
callq 0x67a8
leaq -0xc8(%rbp), %rdi
callq 0x67a8
leaq -0xa8(%rbp), %rdi
callq 0x67a8
jmp 0x2678c
leaq -0xe8(%rbp), %rdi
callq 0x67a8
leaq -0xc8(%rbp), %rdi
callq 0x67a8
leaq -0xa8(%rbp), %rdi
callq 0x67a8
jmp 0x2679a
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq -0x130(%rbp), %rdi
callq 0x6680
nopw %cs:(%rax,%rax)