// File: /workspace/github_cpp_makefile_star2_O1/alfanick[P]rest-cpp/src/rest/request.cpp
// Function: REST::Request::parse_header(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Request::parse_header(std::string const &line) {
  if (line.find("GET") == 0) {
    method = Method::GET;
  } else
  if (line.find("POST") == 0) {
    method = Method::POST;
  } else
  if (line.find("PUT") == 0) {
    method = Method::PUT;
  } else
  if (line.find("DELETE") == 0) {
    method = Method::DELETE;
  } else
  if (line.find("HEAD") == 0) {
    method = Method::HEAD;
  } else
  if (line.find("PATCH") == 0) {
    method = Method::PATCH;
  } else
  if (line.find("TRACE") == 0) {
    method = Method::TRACE;
  } else
  if (line.find("CONNECT") == 0) {
    method = Method::CONNECT;
  } else
  if (line.find("OPTIONS") == 0) {
    method = Method::OPTIONS;
  }

  size_t path_start = line.find_first_of(" ")+1;
  size_t path_end = line.rfind("HTTP/1.")-1;

  path = line.substr(path_start, path_end - path_start);

  // TODO config
  if (path.size() >= 2048)
    throw HTTP::URITooLong();

  size_t path_query = path.find("?");

  if (path_query != std::string::npos) {
    std::string query = path.substr(path_query+1, path.size() - path_query);

    parse_query_string(query);

    path.erase(path_query, query.size()+1);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x19f11(%rip), %rsi     # 0x3e189
xorl %r15d, %r15d
movl $0x3, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23120
testq %rax, %rax
je 0x243b9
leaq 0x19ef3(%rip), %rsi     # 0x3e18d
movl $0x4, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23120
testq %rax, %rax
je 0x24383
leaq 0x19ed9(%rip), %rsi     # 0x3e192
movl $0x3, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23120
testq %rax, %rax
je 0x2438b
leaq 0x19ebe(%rip), %rsi     # 0x3e196
movl $0x6, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23120
testq %rax, %rax
je 0x24393
leaq 0x19ea6(%rip), %rsi     # 0x3e19d
movl $0x4, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23120
testq %rax, %rax
je 0x2439b
leaq 0x19e8c(%rip), %rsi     # 0x3e1a2
movl $0x5, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23120
testq %rax, %rax
je 0x243a3
leaq 0x19e77(%rip), %rsi     # 0x3e1a8
movl $0x5, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23120
testq %rax, %rax
je 0x243ab
leaq 0x19e62(%rip), %rsi     # 0x3e1ae
movl $0x7, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23120
testq %rax, %rax
je 0x243b3
leaq 0x19e4f(%rip), %rsi     # 0x3e1b6
movl $0x7, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23120
testq %rax, %rax
jne 0x243bc
movl $0x7, %r15d
jmp 0x243b9
movl $0x2, %r15d
jmp 0x243b9
movl $0x3, %r15d
jmp 0x243b9
movl $0x4, %r15d
jmp 0x243b9
movl $0x1, %r15d
jmp 0x243b9
movl $0x8, %r15d
jmp 0x243b9
movl $0x5, %r15d
jmp 0x243b9
movl $0x6, %r15d
movl %r15d, (%rbx)
leaq 0x1ad3d(%rip), %rsi     # 0x3f100
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x22c30
movq %rax, %r15
leaq 0x1(%rax), %r12
leaq 0x19dde(%rip), %rsi     # 0x3e1be
movl $0x7, %ecx
movq %r14, %rdi
movq $-0x1, %rdx
callq 0x229c0
subq %r15, %rax
leaq -0x2(%rax), %rcx
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x22330
leaq 0x8(%rbx), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x22620
movq (%r15), %rdi
leaq 0x10(%rsp), %r13
cmpq %r13, %rdi
je 0x2442d
callq 0x22130
cmpq $0x800, 0x10(%rbx)      # imm = 0x800
jae 0x244a9
leaq 0x19d88(%rip), %rsi     # 0x3e1c6
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23120
cmpq $-0x1, %rax
je 0x2449b
movq %rax, %r15
leaq 0x1(%rax), %rdx
movq 0x10(%rbx), %rcx
subq %rax, %rcx
movq %rsp, %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x22330
movq %rbx, %rdi
movq %r12, %rsi
callq 0x22960
movq 0x8(%rsp), %rdx
incq %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x212d0
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x2449b
callq 0x22130
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl $0x8, %edi
callq 0x217b0
movq 0x299de(%rip), %rcx     # 0x4de98
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x299b0(%rip), %rsi     # 0x4de78
movq 0x29ae9(%rip), %rdx     # 0x4dfb8
movq %rax, %rdi
callq 0x230a0
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x244e8
callq 0x22130
movq %rbx, %rdi
callq 0x23170