// File: /workspace/github_cpp_makefile_star2_O3/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 0x36f58
leaq 0x2ae11(%rip), %rsi     # 0x3a813
movq %r15, %rdi
callq 0x7180
testl %eax, %eax
movq %rbx, 0x20(%rsp)
je 0xfa88
movq %r14, %rdi
callq 0x2b16e
movq %rax, %r14
movq (%rax), %rbx
cmpq %rax, %rbx
je 0xfaa5
leaq 0x10(%rsp), %rbp
movq %rsp, %r15
leaq 0x48(%rsp), %r12
leaq 0x2ae11(%rip), %r13     # 0x3a84b
cmpq (%r14), %rbx
je 0xfa4a
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 0xfa7e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%rbx), %rbx
cmpq %r14, %rbx
jne 0xfa3a
jmp 0xfaa5
leaq 0x48(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x2ad7d(%rip), %rcx     # 0x3a815
movl $0x35, %r8d
xorl %esi, %esi
callq 0x76f0
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2a5ee(%rip), %rsi     # 0x3a0a3
leaq 0x2a5ec(%rip), %rdx     # 0x3a0a8
movq %rsp, %rdi
callq 0x80f4
movq %rsp, %rsi
leaq 0x48(%rsp), %rdx
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x37020
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xfaef
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
movq %rbx, %rdi
callq 0x373a0
movq %rsp, %rdi
movq %r15, (%rdi)
leaq 0x2a793(%rip), %rsi     # 0x3a297
leaq 0x2a792(%rip), %rdx     # 0x3a29d
callq 0x80f4
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2b0bb(%rip), %rsi     # 0x3abdc
leaq 0x2b0bb(%rip), %rdx     # 0x3abe3
leaq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rbx
callq 0x80f4
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x37020
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0xfb5e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xfb74
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
movq %rsp, %rdi
movq %r15, (%rdi)
leaq 0x2a583(%rip), %rsi     # 0x3a104
leaq 0x2a58a(%rip), %rdx     # 0x3a112
callq 0x80f4
leaq 0x28(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x2b67f(%rip), %rsi     # 0x3b21b
leaq 0x2b679(%rip), %rdx     # 0x3b21c
callq 0x80f4
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x37020
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0xfbcf
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%rsp), %rdi
cmpq %r15, %rdi
leaq 0x58(%rsp), %r14
je 0xfbea
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0xfc01
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 0xfc54
jmp 0xfc1b
jmp 0xfc3b
jmp 0xfc54
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0xfc3e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0xfc3e
jmp 0xfc3b
jmp 0xfc54
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
jne 0xfc65
jmp 0xfc72
jmp 0xfc54
movq %rax, %r14
jmp 0xfc7c
jmp 0xfc54
jmp 0xfc54
movq %rax, %r14
jmp 0xfc72
movq %rax, %r14
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0xfc72
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x20(%rsp), %rdi
callq 0x36d9a
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xfc98
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x74b0
movq %r14, %rdi
callq 0x7810