// File: /workspace/github_cpp_makefile_star2_O1/mbourand[P]webserv/srcs/Methods/OptionsMethod.cpp
// Function: OptionsMethod::process(Request const&, ConfigContext const&, ServerSocket const&)
Response OptionsMethod::process(const Request& request, const ConfigContext& config, const ServerSocket&)
{
	std::string	allowed_header;
	Response response(200, request._url._path);

	if (request._url._path == "*")
		allowed_header = "CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PUT, TRACE";
	else
	{
		const std::list<const IMethod*>& allowedMethods = config.getAllowedMethods();
		for (std::list<const IMethod*>::const_iterator it = allowedMethods.begin(); it != allowedMethods.end(); it++)
		{
			if (it != allowedMethods.begin())
				allowed_header += ", ";
			allowed_header += (*it)->getType();
		}
	}
	response.addHeader("Allow", allowed_header);
	response.addDateHeader();
	response.addHeader("Server", "Webserv");
	response.addHeader("Content-Length", "0");
	return (response);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rdi, %rbx
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
addq $0xb8, %r15
movl $0xc8, %esi
movq %r15, %rdx
callq 0x37384
leaq 0x2ae05(%rip), %rsi     # 0x3a813
movq %r15, %rdi
callq 0x7180
testl %eax, %eax
movq %rbx, 0x20(%rsp)
je 0xfa94
movq %r14, %rdi
callq 0x2b4b6
movq %rax, %r14
movq (%rax), %rbx
cmpq %rax, %rbx
je 0xfab1
leaq 0x10(%rsp), %rbp
movq %rsp, %r15
leaq 0x48(%rsp), %r12
leaq 0x2ae05(%rip), %r13     # 0x3a84b
cmpq (%r14), %rbx
je 0xfa56
movq %r12, %rdi
movq %r13, %rsi
callq 0x78d0
movq 0x10(%rbx), %rsi
movq (%rsi), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r12, %rdi
callq 0x7190
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0xfa8a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%rbx), %rbx
cmpq %r14, %rbx
jne 0xfa46
jmp 0xfab1
leaq 0x48(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x2ad71(%rip), %rcx     # 0x3a815
movl $0x35, %r8d
xorl %esi, %esi
callq 0x76f0
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2a5e2(%rip), %rsi     # 0x3a0a3
leaq 0x2a5e0(%rip), %rdx     # 0x3a0a8
movq %rsp, %rdi
callq 0x80f4
movq %rsp, %rsi
leaq 0x48(%rsp), %rdx
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x3744c
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xfafb
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
movq %rbx, %rdi
callq 0x377cc
movq %rsp, %rdi
movq %r15, (%rdi)
leaq 0x2a787(%rip), %rsi     # 0x3a297
leaq 0x2a786(%rip), %rdx     # 0x3a29d
callq 0x80f4
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2b0af(%rip), %rsi     # 0x3abdc
leaq 0x2b0af(%rip), %rdx     # 0x3abe3
leaq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rbx
callq 0x80f4
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x3744c
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0xfb6a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xfb80
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
movq %rsp, %rdi
movq %r15, (%rdi)
leaq 0x2a577(%rip), %rsi     # 0x3a104
leaq 0x2a57e(%rip), %rdx     # 0x3a112
callq 0x80f4
leaq 0x28(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x2b673(%rip), %rsi     # 0x3b21b
leaq 0x2b66d(%rip), %rdx     # 0x3b21c
callq 0x80f4
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x3744c
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0xfbdb
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%rsp), %rdi
cmpq %r15, %rdi
leaq 0x58(%rsp), %r14
je 0xfbf6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0xfc0d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x74b0
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xfc60
jmp 0xfc27
jmp 0xfc47
jmp 0xfc60
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0xfc4a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0xfc4a
jmp 0xfc47
jmp 0xfc60
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
jne 0xfc71
jmp 0xfc7e
jmp 0xfc60
movq %rax, %r14
jmp 0xfc88
jmp 0xfc60
jmp 0xfc60
movq %rax, %r14
jmp 0xfc7e
movq %rax, %r14
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0xfc7e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x20(%rsp), %rdi
callq 0x371c6
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xfca4
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x74b0
movq %r14, %rdi
callq 0x7810