// File: llefranc[P]42_webserv/srcs/server/Response.cpp
// Function: Response::execGet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Response::execGet(const std::string& realUri)
{
    // Storing status line and some headers in buffer
    fillStatusLine(_staLine);
    fillServerHeader();
    fillDateHeader();
    
    if (!_autoIndex)
    {
        FileParser body(realUri.c_str(), true); // CAHNGER

        // Setting size after storing the body in FileParser object, then setting Last-Modified header
        fillContentlengthHeader(convertNbToString(body.getRequestFileSize()));
        fillLastModifiedHeader(realUri.c_str());
        _buffer += CLRF;

        // For GET, writing the body previously stored to the buffer
        if (_req->getMethod() == GET)
            _buffer += body.getRequestFile();
    }

    // Filling autoindex
    else
    {
        std::string autoIndexPage;
        autoIndexDisplayer(realUri, &autoIndexPage);

        fillContentlengthHeader(convertNbToString(autoIndexPage.size()));
        _buffer += CLRF + autoIndexPage;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3b0, %rsp            # imm = 0x3B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x380(%rbp)
movq %rdi, %rsi
addq $0x10, %rsi
callq 0x1cb90
movq -0x380(%rbp), %rdi
callq 0x1cdc0
movq -0x380(%rbp), %rdi
callq 0x1cdf0
movq -0x380(%rbp), %rax
testb $0x1, 0x78(%rax)
jne 0x1c7ce
movq -0x10(%rbp), %rdi
callq 0x5240
movq %rax, %rsi
leaq -0x2e8(%rbp), %rdi
movq %rdi, -0x390(%rbp)
movl $0x1, %edx
callq 0xb170
movq -0x390(%rbp), %rdi
callq 0xb810
movq %rax, -0x388(%rbp)
jmp 0x1c6bc
movq -0x388(%rbp), %rsi
leaq -0x308(%rbp), %rdi
callq 0x20c10
jmp 0x1c6d1
movq -0x380(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0x1d230
jmp 0x1c6e6
leaq -0x308(%rbp), %rdi
callq 0x5a08
movq -0x10(%rbp), %rdi
callq 0x5240
movq -0x380(%rbp), %rdi
movq %rax, %rsi
callq 0x1d2e0
jmp 0x1c70c
movq -0x380(%rbp), %rdi
addq $0x58, %rdi
leaq 0x7557(%rip), %rsi      # 0x23c75
callq 0x5520
jmp 0x1c725
movq -0x380(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x174a0
movl %eax, -0x394(%rbp)
jmp 0x1c73d
movl -0x394(%rbp), %eax
cmpl $0x0, %eax
jne 0x1c7ac
leaq -0x2e8(%rbp), %rdi
callq 0xb630
movq %rax, -0x3a0(%rbp)
jmp 0x1c75d
movq -0x3a0(%rbp), %rsi
movq -0x380(%rbp), %rdi
addq $0x58, %rdi
callq 0x56b0
jmp 0x1c776
jmp 0x1c7ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x310(%rbp)
movl %eax, -0x314(%rbp)
jmp 0x1c7bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x310(%rbp)
movl %eax, -0x314(%rbp)
leaq -0x308(%rbp), %rdi
callq 0x5a08
jmp 0x1c7bd
leaq -0x2e8(%rbp), %rdi
callq 0xb5a0
jmp 0x1c8e0
leaq -0x2e8(%rbp), %rdi
callq 0xb5a0
jmp 0x1c8e9
leaq -0x338(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x5770
movq -0x3a8(%rbp), %rsi
movq -0x10(%rbp), %rdi
callq 0x22120
jmp 0x1c7f3
leaq -0x338(%rbp), %rdi
callq 0x53b0
movq %rax, %rsi
leaq -0x358(%rbp), %rdi
callq 0x20c10
jmp 0x1c810
movq -0x380(%rbp), %rdi
leaq -0x358(%rbp), %rsi
callq 0x1d230
jmp 0x1c825
leaq -0x358(%rbp), %rdi
callq 0x5a08
leaq 0x743d(%rip), %rsi      # 0x23c75
leaq -0x378(%rbp), %rdi
leaq -0x338(%rbp), %rdx
callq 0x9a60
jmp 0x1c84d
movq -0x380(%rbp), %rdi
addq $0x58, %rdi
leaq -0x378(%rbp), %rsi
callq 0x56b0
jmp 0x1c866
leaq -0x378(%rbp), %rdi
callq 0x5a08
leaq -0x338(%rbp), %rdi
callq 0x5a08
jmp 0x1c8e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x310(%rbp)
movl %eax, -0x314(%rbp)
jmp 0x1c8d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x310(%rbp)
movl %eax, -0x314(%rbp)
leaq -0x358(%rbp), %rdi
callq 0x5a08
jmp 0x1c8d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x310(%rbp)
movl %eax, -0x314(%rbp)
leaq -0x378(%rbp), %rdi
callq 0x5a08
leaq -0x338(%rbp), %rdi
callq 0x5a08
jmp 0x1c8e9
addq $0x3b0, %rsp            # imm = 0x3B0
popq %rbp
retq
movq -0x310(%rbp), %rdi
callq 0x58e0
nopw %cs:(%rax,%rax)