// File: /workspace/github_cpp_makefile_star2_O2/trisolaris233[P]httpc/src/request_handler.cpp
// Function: httpc::RequestHandler::Respond(httpc::Request&, httpc::Response&)
void RequestHandler::Respond(Request& request, Response& response) {
        if (response.Empty()) {
            //std::cout << "empty" << std::endl;
            // check whether http version is supported
            auto HttpVersionSupported = GetHttpVersionSupported();
            if (std::find(
                HttpVersionSupported.begin(), 
                HttpVersionSupported.end(), 
                request.http_major_version * 10 + request.http_minor_version
            ) == HttpVersionSupported.end()) {
                //debug().dg("ver").lf();
                response.SetDefault(HTTPStatusCodeEnum::kHTTPVersionNotSupported);
                return;
            }

            // check whether the http method is supported
            auto HttpMethodSupported = GetHttpMethodSupported();
            if (std::find(
                HttpMethodSupported.begin(),
                HttpMethodSupported.end(), 
                request.method
            ) == HttpMethodSupported.end()) {
                response.SetDefault(HTTPStatusCodeEnum::kMethodNotAllowed);
                return;
            }

            return response.SetDefault(HTTPStatusCodeEnum::kNotFound);   
        }
        
        response.http_major_version = request.http_major_version;
        response.http_minor_version = request.http_minor_version;

        if (response.http_major_version == 1) {
            // http/1.1
            if (response.http_minor_version == 1 || response.http_minor_version == 0) {
                if (response.IsEmptyReasonPhrase() || response.IsEmptyStatusCode()) {
                    response.SetStatusCode(HTTPStatusCodeEnum::kOk);
                }
                if (response.IsEmptyMessageBody()) {
                    response.RenderString(GetHTTPReasonPhrase(response.status_code));
                }
                
                response.SetDefaultHeaders();
            }
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdx, %rdi
callq 0x1fec8
testb %al, %al
je 0x1fdfd
callq 0x1f7cb
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x1fef4
movq (%r15), %rdi
movq 0x8(%r15), %rsi
imull $0xa, 0x90(%r14), %eax
addl 0x94(%r14), %eax
leaq -0x30(%rbp), %rdx
movl %eax, (%rdx)
callq 0x2004a
cmpq -0x48(%rbp), %rax
je 0x1fe71
callq 0x1f84e
leaq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x1ff4c
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq %r14, %rdx
callq 0x2016f
xorl %esi, %esi
cmpq -0x28(%rbp), %rax
sete %sil
orl $0x194, %esi            # imm = 0x194
movq %rbx, %rdi
callq 0x9b8a
leaq -0x30(%rbp), %rdi
callq 0x1a7c2
jmp 0x1fe7e
movl 0x90(%r14), %eax
movl %eax, (%rbx)
movl 0x94(%r14), %ecx
movl %ecx, 0x4(%rbx)
cmpl $0x1, %eax
sete %al
cmpl $0x2, %ecx
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1fe87
cmpq $0x0, 0x18(%rbx)
je 0x1fe30
cmpl $0x0, 0x8(%rbx)
jne 0x1fe3d
movq %rbx, %rdi
movl $0xc8, %esi
callq 0x1ffa0
cmpq $0x0, 0x50(%rbx)
jne 0x1fe67
movl 0x8(%rbx), %esi
leaq -0x50(%rbp), %r14
movq %r14, %rdi
callq 0x1f2d0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x20264
leaq -0x50(%rbp), %rdi
callq 0x8280
movq %rbx, %rdi
callq 0x1ffde
jmp 0x1fe87
movq %rbx, %rdi
movl $0x1f9, %esi            # imm = 0x1F9
callq 0x9b8a
leaq -0x50(%rbp), %rdi
callq 0x1fac6
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x8280
jmp 0x1fec0
jmp 0x1feb4
jmp 0x1fea4
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x1a7c2
jmp 0x1feb7
jmp 0x1feb4
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1fac6
movq %rbx, %rdi
callq 0x8850