// File: llefranc[P]42_webserv/srcs/server/ClientSocket.cpp
// Function: ClientSocket::receiveRequest(char const*)
int ClientSocket::receiveRequest(const char* buffer)
{
	try
	{
		_request += buffer;
		_request.parsingCheck();
	}

	// Setting the response with the StatusLine previously sent, and with this request
	// object containing the full request
	catch (const StatusLine& staLine)
	{
		printLog(" >> FD " + convertNbToString(getFd()) + ": Request received\n");
		printLog(" >> FD " + convertNbToString(getFd()) + ": URI: " + _request.getPath() + "\n");

        // Constructing response
        _response.setRequest(&_request);
        _response.setStatusLine(staLine);
        _response.setInfoVirtualServs(_infoVirServs);
		_response.fillBuffer();
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x180(%rbp)
movq -0x10(%rbp), %rsi
addq $0x10, %rdi
callq 0x17530
jmp 0x1698d
movq -0x180(%rbp), %rdi
addq $0x10, %rdi
callq 0x17560
jmp 0x1699f
jmp 0x16c39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x16d78
movq -0x18(%rbp), %rdi
callq 0x5230
movq -0x180(%rbp), %rdi
movq %rax, -0x28(%rbp)
callq 0x168f0
movslq %eax, %rsi
leaq -0x88(%rbp), %rdi
callq 0x20c10
jmp 0x169ea
leaq 0xca1e(%rip), %rsi      # 0x2340f
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x6700
jmp 0x16a03
leaq 0xcbcc(%rip), %rdx      # 0x235d6
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x66b0
jmp 0x16a19
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x58f0
movq -0x188(%rbp), %rdx
leaq 0xccd2(%rip), %rsi      # 0x2370c
leaq -0xa8(%rbp), %rdi
callq 0x63e0
jmp 0x16a48
leaq -0x48(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x21750
jmp 0x16a5a
leaq -0xa8(%rbp), %rdi
callq 0x5a08
leaq -0xa9(%rbp), %rdi
callq 0x55c0
leaq -0x48(%rbp), %rdi
callq 0x5a08
leaq -0x68(%rbp), %rdi
callq 0x5a08
leaq -0x88(%rbp), %rdi
callq 0x5a08
movq -0x180(%rbp), %rdi
callq 0x168f0
movslq %eax, %rsi
leaq -0x150(%rbp), %rdi
callq 0x20c10
jmp 0x16aad
leaq 0xc95b(%rip), %rsi      # 0x2340f
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rdx
callq 0x6700
jmp 0x16ac9
leaq 0xcb1a(%rip), %rdx      # 0x235ea
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x66b0
jmp 0x16ae5
movq -0x180(%rbp), %rdi
addq $0x10, %rdi
callq 0x174c0
movq %rax, -0x190(%rbp)
jmp 0x16afe
movq -0x190(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x16dc0
jmp 0x16b1a
leaq 0xc8a9(%rip), %rdx      # 0x233ca
leaq -0xd0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x66b0
jmp 0x16b36
leaq -0x171(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x58f0
movq -0x198(%rbp), %rdx
leaq 0xcbb5(%rip), %rsi      # 0x2370c
leaq -0x170(%rbp), %rdi
callq 0x63e0
jmp 0x16b65
leaq -0xd0(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x21750
jmp 0x16b7a
leaq -0x170(%rbp), %rdi
callq 0x5a08
leaq -0x171(%rbp), %rdi
callq 0x55c0
leaq -0xd0(%rbp), %rdi
callq 0x5a08
leaq -0xf0(%rbp), %rdi
callq 0x5a08
leaq -0x110(%rbp), %rdi
callq 0x5a08
leaq -0x130(%rbp), %rdi
callq 0x5a08
leaq -0x150(%rbp), %rdi
callq 0x5a08
movq -0x180(%rbp), %rsi
movq %rsi, %rdi
addq $0xf0, %rdi
addq $0x10, %rsi
callq 0x1ab70
jmp 0x16bea
movq -0x180(%rbp), %rdi
addq $0xf0, %rdi
movq -0x28(%rbp), %rsi
callq 0x1ab90
jmp 0x16c03
movq -0x180(%rbp), %rax
movq %rax, %rdi
addq $0xf0, %rdi
movq 0x8(%rax), %rsi
callq 0x1ac00
jmp 0x16c1f
movq -0x180(%rbp), %rdi
addq $0xf0, %rdi
callq 0x1acb0
jmp 0x16c34
callq 0x5860
xorl %eax, %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x16d6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x16cb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x16cac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x16c97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5a08
leaq -0xa9(%rbp), %rdi
callq 0x55c0
leaq -0x48(%rbp), %rdi
callq 0x5a08
leaq -0x68(%rbp), %rdi
callq 0x5a08
leaq -0x88(%rbp), %rdi
callq 0x5a08
jmp 0x16d6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x16d63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x16d57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x16d4b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x16d3f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x16d27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x5a08
leaq -0x171(%rbp), %rdi
callq 0x55c0
leaq -0xd0(%rbp), %rdi
callq 0x5a08
leaq -0xf0(%rbp), %rdi
callq 0x5a08
leaq -0x110(%rbp), %rdi
callq 0x5a08
leaq -0x130(%rbp), %rdi
callq 0x5a08
leaq -0x150(%rbp), %rdi
callq 0x5a08
callq 0x5860
jmp 0x16d76
jmp 0x16d78
movq -0x18(%rbp), %rdi
callq 0x58e0
movq %rax, %rdi
callq 0x64e0
nopl (%rax)