// File: white0dew[P]WebServer/http/http_conn.cpp
// Function: http_conn::parse_headers(char*)
http_conn::HTTP_CODE http_conn::parse_headers(char *text)
{
    //判断是空行还是请求头
    if (text[0] == '\0')
    {
        //判断是GET还是POST请求
        //!0 is POST
        if (m_content_length != 0)
        {
            //POST需要跳转到消息体处理状态
            m_check_state = CHECK_STATE_CONTENT;
            return NO_REQUEST;
        }
        //==0 is GET
        return GET_REQUEST;
    }
    //解析请求头部connection字段
    else if (strncasecmp(text, "Connection:", 11) == 0)
    {
        text += 11;

        //跳过空格和\t字符
        text += strspn(text, " \t");
        if (strcasecmp(text, "keep-alive") == 0)
        {
            //如果是长连接，则将linger标志设置为true
            m_linger = true;
        }
    }
    //解析请求头部Content-length字段
    else if (strncasecmp(text, "Content-length:", 15) == 0)
    {
        text += 15;
        text += strspn(text, " \t");
        m_content_length = atol(text);
    }
    //解析请求头部Host字段
    else if (strncasecmp(text, "Host:", 5) == 0)
    {
        text += 5;
        text += strspn(text, " \t");
        m_host = text;
    }
    else
    {
        LOG_INFO("oop!unknow header: %s", text);
    }
    return NO_REQUEST;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x55f7
movq -0x20(%rbp), %rax
cmpl $0x0, 0xd20(%rax)
je 0x55eb
movq -0x20(%rbp), %rax
movl $0x2, 0xc38(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x574e
movl $0x1, -0x4(%rbp)
jmp 0x574e
movq -0x18(%rbp), %rdi
leaq 0x8c5e(%rip), %rsi      # 0xe260
movl $0xb, %edx
callq 0x35b0
cmpl $0x0, %eax
jne 0x565a
movq -0x18(%rbp), %rax
addq $0xb, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x8c07(%rip), %rsi      # 0xe22f
callq 0x3190
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x8c2c(%rip), %rsi      # 0xe26c
callq 0x34c0
cmpl $0x0, %eax
jne 0x5655
movq -0x20(%rbp), %rax
movb $0x1, 0xd24(%rax)
jmp 0x5745
movq -0x18(%rbp), %rdi
leaq 0x8c12(%rip), %rsi      # 0xe277
movl $0xf, %edx
callq 0x35b0
cmpl $0x0, %eax
jne 0x56b3
movq -0x18(%rbp), %rax
addq $0xf, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x8ba4(%rip), %rsi      # 0xe22f
callq 0x3190
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3560
movq %rax, %rcx
movq -0x20(%rbp), %rax
movl %ecx, 0xd20(%rax)
jmp 0x5743
movq -0x18(%rbp), %rdi
leaq 0x8bc9(%rip), %rsi      # 0xe287
movl $0x5, %edx
callq 0x35b0
cmpl $0x0, %eax
jne 0x5705
movq -0x18(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x8b4b(%rip), %rsi      # 0xe22f
callq 0x3190
movq %rax, %rcx
movq -0x20(%rbp), %rax
addq -0x18(%rbp), %rcx
movq %rcx, -0x18(%rbp)
movq -0x18(%rbp), %rcx
movq %rcx, 0xd18(%rax)
jmp 0x5741
movq -0x20(%rbp), %rcx
xorl %eax, %eax
cmpl 0xe34(%rcx), %eax
jne 0x573f
callq 0x6d70
movq %rax, %rdi
movq -0x18(%rbp), %rcx
movl $0x1, %esi
leaq 0x8b62(%rip), %rdx      # 0xe28d
movb $0x0, %al
callq 0x9280
callq 0x6d70
movq %rax, %rdi
callq 0x97f0
jmp 0x5741
jmp 0x5743
jmp 0x5745
jmp 0x5747
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)