// File: /workspace/github_cpp_makefile_star2_O3/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
leaq 0x18f3c(%rip), %rsi     # 0x3d189
movl $0x3, %ecx
movq %rdi, %rbx
xorl %r15d, %r15d
movq %r14, %rdi
xorl %edx, %edx
callq 0x23110
testq %rax, %rax
je 0x24391
leaq 0x18f1b(%rip), %rsi     # 0x3d18d
movl $0x4, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23110
testq %rax, %rax
je 0x2435b
leaq 0x18f01(%rip), %rsi     # 0x3d192
movl $0x3, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23110
testq %rax, %rax
je 0x24363
leaq 0x18ee6(%rip), %rsi     # 0x3d196
movl $0x6, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23110
testq %rax, %rax
je 0x2436b
leaq 0x18ece(%rip), %rsi     # 0x3d19d
movl $0x4, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23110
testq %rax, %rax
je 0x24373
leaq 0x18eb4(%rip), %rsi     # 0x3d1a2
movl $0x5, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23110
testq %rax, %rax
je 0x2437b
leaq 0x18e9f(%rip), %rsi     # 0x3d1a8
movl $0x5, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23110
testq %rax, %rax
je 0x24383
leaq 0x18e8a(%rip), %rsi     # 0x3d1ae
movl $0x7, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23110
testq %rax, %rax
je 0x2438b
leaq 0x18e77(%rip), %rsi     # 0x3d1b6
movl $0x7, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23110
testq %rax, %rax
jne 0x24394
movl $0x7, %r15d
jmp 0x24391
movl $0x2, %r15d
jmp 0x24391
movl $0x3, %r15d
jmp 0x24391
movl $0x4, %r15d
jmp 0x24391
movl $0x1, %r15d
jmp 0x24391
movl $0x8, %r15d
jmp 0x24391
movl $0x5, %r15d
jmp 0x24391
movl $0x6, %r15d
movl %r15d, (%rbx)
leaq 0x19d65(%rip), %rsi     # 0x3e100
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x22c30
leaq 0x18e0d(%rip), %rsi     # 0x3d1be
movl $0x7, %ecx
movq $-0x1, %rdx
movq %r14, %rdi
movq %rax, %r15
leaq 0x1(%rax), %r12
callq 0x229c0
subq %r15, %rax
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
leaq -0x2(%rax), %rcx
callq 0x22330
leaq 0x8(%rbx), %r14
movq %r15, %rsi
movq %r14, %rdi
callq 0x22620
movq (%r15), %rdi
leaq 0x10(%rsp), %r13
cmpq %r13, %rdi
je 0x24405
callq 0x22130
cmpq $0x800, 0x10(%rbx)      # imm = 0x800
jae 0x24481
leaq 0x18db0(%rip), %rsi     # 0x3d1c6
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x23110
cmpq $-0x1, %rax
je 0x24473
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rsp, %r12
movq %rax, %r15
movq %r12, %rdi
movq %r14, %rsi
subq %rax, %rcx
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 0x24473
callq 0x22130
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl $0x8, %edi
callq 0x217b0
movq 0x28a06(%rip), %rcx     # 0x4ce98
movq 0x289df(%rip), %rsi     # 0x4ce78
movq 0x28b18(%rip), %rdx     # 0x4cfb8
movq %rax, %rdi
addq $0x10, %rcx
movq %rcx, (%rax)
callq 0x23090
movq (%rsp), %rdi
movq %rax, %rbx
cmpq %r13, %rdi
je 0x244c0
callq 0x22130
movq %rbx, %rdi
callq 0x23160