// File: /workspace/github_cpp_makefile_star2_O3/JianjiaoSQ[P]MyPoorWebServer/http/http_conn.cpp
// Function: http_conn::parse_request_line(char*)
http_conn::HTTP_CODE http_conn::parse_request_line(char *text)
{
    m_url = strpbrk(text, " \t");  // 搜索返回位置
    if (!m_url)
    {
        return BAD_REQUEST;
    }
    *m_url++ = '\0';
    char *method = text;
    if (strcasecmp(method, "GET") == 0) // 判断字符串是否相等，忽略大小写
        m_method = GET;
    else if (strcasecmp(method, "POST") == 0)
    {
        m_method = POST;
        cgi = 1;
    }
    else
        return BAD_REQUEST;
    m_url += strspn(m_url, " \t"); // 该函数返回 str1 中第一个不在字符串 str2 中出现的字符下标。

    m_version = strpbrk(m_url, " \t");
    if (!m_version)
        return BAD_REQUEST;
    *m_version++ = '\0';
    m_version += strspn(m_version, " \t");
    if (strcasecmp(m_version, "HTTP/1.1") != 0)
        return BAD_REQUEST;
    if (strncasecmp(m_url, "http://", 7) == 0) // 比较参数 s1 和  s2 字符串前n个字符
    {
        m_url += 7;
        m_url = strchr(m_url, '/');
    }

    if (strncasecmp(m_url, "https://", 8) == 0)
    {
        m_url += 8;
        m_url = strchr(m_url, '/');
    }

    if (!m_url || m_url[0] != '/')
        return BAD_REQUEST;
    //当url为/时，显示判断界面
    if (strlen(m_url) == 1)
        strcat(m_url, "judge.html");
    m_check_state = CHECK_STATE_HEADER;
    return NO_REQUEST;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x4a8d(%rip), %rsi      # 0x922f
movq %r14, %rdi
callq 0x35d0
movq %rax, 0xd08(%rbx)
movl $0x2, %ebp
testq %rax, %rax
je 0x4896
movq %rax, %rcx
incq %rcx
movq %rcx, 0xd08(%rbx)
movb $0x0, (%rax)
leaq 0x4a5c(%rip), %rsi      # 0x9232
movq %r14, %rdi
callq 0x33d0
testl %eax, %eax
je 0x480f
leaq 0x4a4d(%rip), %rsi      # 0x9236
movq %r14, %rdi
callq 0x33d0
testl %eax, %eax
jne 0x4896
movl $0x1, 0xc3c(%rbx)
movl $0x1, %eax
movl $0xde4, %ecx            # imm = 0xDE4
jmp 0x4816
xorl %eax, %eax
movl $0xc3c, %ecx            # imm = 0xC3C
movl %eax, (%rbx,%rcx)
movq 0xd08(%rbx), %r14
leaq 0x4a08(%rip), %r15      # 0x922f
movq %r14, %rdi
movq %r15, %rsi
callq 0x3140
addq %rax, %r14
movq %r14, 0xd08(%rbx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x35d0
movq %rax, 0xd10(%rbx)
testq %rax, %rax
je 0x4896
movq %rax, %rcx
incq %rcx
movq %rcx, 0xd10(%rbx)
movb $0x0, (%rax)
movq 0xd10(%rbx), %r14
leaq 0x49be(%rip), %rsi      # 0x922f
movq %r14, %rdi
callq 0x3140
addq %rax, %r14
movq %r14, 0xd10(%rbx)
leaq 0x49b1(%rip), %rsi      # 0x923b
movq %r14, %rdi
callq 0x33d0
testl %eax, %eax
je 0x48a3
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xd08(%rbx), %r14
leaq 0x4993(%rip), %rsi      # 0x9244
movl $0x7, %edx
movq %r14, %rdi
callq 0x34a0
testl %eax, %eax
jne 0x48e4
addq $0x7, %r14
movq %r14, 0xd08(%rbx)
movq %r14, %rdi
movl $0x2f, %esi
callq 0x3120
movq %rax, %r14
movq %rax, 0xd08(%rbx)
leaq 0x4961(%rip), %rsi      # 0x924c
movl $0x8, %edx
movq %r14, %rdi
callq 0x34a0
testl %eax, %eax
jne 0x491e
addq $0x8, %r14
movq %r14, 0xd08(%rbx)
movq %r14, %rdi
movl $0x2f, %esi
callq 0x3120
movq %rax, %r14
movq %rax, 0xd08(%rbx)
testq %r14, %r14
je 0x4896
cmpb $0x2f, (%r14)
jne 0x4896
movq %r14, %rdi
callq 0x3150
cmpq $0x1, %rax
jne 0x495e
movq %r14, %rdi
callq 0x3150
movabsq $0x74682e656764756a, %rcx # imm = 0x74682E656764756A
movq %rcx, (%r14,%rax)
movl $0x6c6d74, 0x7(%r14,%rax) # imm = 0x6C6D74
movl $0x1, 0xc38(%rbx)
xorl %ebp, %ebp
jmp 0x4896
nop