// File: 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
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x178(%rbp)
movq %rdi, %rax
movq %rax, -0x180(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x98c0
movq -0x178(%rbp), %rdi
movb $0x0, -0x49(%rbp)
movq -0x18(%rbp), %rdx
addq $0xb8, %rdx
movl $0xc8, %esi
callq 0x636c0
jmp 0x17efb
movq -0x18(%rbp), %rdi
addq $0xb8, %rdi
leaq 0x528ca(%rip), %rsi     # 0x6a7d7
callq 0xdf50
movb %al, -0x181(%rbp)
jmp 0x17f1a
movb -0x181(%rbp), %al
testb $0x1, %al
jne 0x17f26
jmp 0x17f5f
leaq 0x528ac(%rip), %rsi     # 0x6a7d9
leaq -0x48(%rbp), %rdi
callq 0x98a0
jmp 0x17f38
jmp 0x18052
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x18343
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x18337
movq -0x20(%rbp), %rdi
callq 0x4c6d0
movq %rax, -0x190(%rbp)
jmp 0x17f71
movq -0x190(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x18360
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
callq 0x183c0
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x18390
testb $0x1, %al
jne 0x17fac
jmp 0x18050
movq -0x68(%rbp), %rdi
callq 0x18360
movq %rax, -0x80(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x18390
testb $0x1, %al
jne 0x17fcc
jmp 0x17fe0
leaq 0x5283c(%rip), %rsi     # 0x6a80f
leaq -0x48(%rbp), %rdi
callq 0x9650
jmp 0x17fde
jmp 0x17fe0
leaq -0x70(%rbp), %rdi
callq 0x183f0
movq (%rax), %rsi
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0xa0(%rbp), %rdi
callq *%rax
jmp 0x17ffe
leaq -0x48(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x9830
jmp 0x18010
leaq -0xa0(%rbp), %rdi
callq 0x9c98
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x18420
movq %rax, -0xa8(%rbp)
jmp 0x17f89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x9c98
jmp 0x18337
jmp 0x18052
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x9b10
movq -0x198(%rbp), %rdx
leaq 0x52030(%rip), %rsi     # 0x6a0a3
leaq -0xc8(%rbp), %rdi
callq 0xa780
jmp 0x18081
movq -0x178(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x63770
jmp 0x1809a
leaq -0xc8(%rbp), %rdi
callq 0x9c98
leaq -0xc9(%rbp), %rdi
callq 0x9700
movq -0x178(%rbp), %rdi
callq 0x63a60
jmp 0x180c0
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x9b10
movq -0x1a0(%rbp), %rdx
leaq 0x5216b(%rip), %rsi     # 0x6a24c
leaq -0xf0(%rbp), %rdi
callq 0xa780
jmp 0x180ef
leaq -0x119(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x9b10
movq -0x1a8(%rbp), %rdx
leaq 0x52aa1(%rip), %rsi     # 0x6abb1
leaq -0x118(%rbp), %rdi
callq 0xa780
jmp 0x1811e
movq -0x178(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x63770
jmp 0x1813a
leaq -0x118(%rbp), %rdi
callq 0x9c98
leaq -0x119(%rbp), %rdi
callq 0x9700
leaq -0xf0(%rbp), %rdi
callq 0x9c98
leaq -0xf1(%rbp), %rdi
callq 0x9700
leaq -0x141(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x9b10
movq -0x1b0(%rbp), %rdx
leaq 0x51f79(%rip), %rsi     # 0x6a104
leaq -0x140(%rbp), %rdi
callq 0xa780
jmp 0x18199
leaq -0x169(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x9b10
movq -0x1b8(%rbp), %rdx
leaq 0x5343d(%rip), %rsi     # 0x6b5f7
leaq -0x168(%rbp), %rdi
callq 0xa780
jmp 0x181c8
movq -0x178(%rbp), %rdi
leaq -0x140(%rbp), %rsi
leaq -0x168(%rbp), %rdx
callq 0x63770
jmp 0x181e4
leaq -0x168(%rbp), %rdi
callq 0x9c98
leaq -0x169(%rbp), %rdi
callq 0x9700
leaq -0x140(%rbp), %rdi
callq 0x9c98
leaq -0x141(%rbp), %rdi
callq 0x9700
movb $0x1, -0x49(%rbp)
testb $0x1, -0x49(%rbp)
jne 0x1831e
jmp 0x18312
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1824d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x9c98
leaq -0xc9(%rbp), %rdi
callq 0x9700
jmp 0x18337
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x182aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x18292
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x9c98
leaq -0x119(%rbp), %rdi
callq 0x9700
leaq -0xf0(%rbp), %rdi
callq 0x9c98
leaq -0xf1(%rbp), %rdi
callq 0x9700
jmp 0x18337
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x18304
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x182ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x9c98
leaq -0x169(%rbp), %rdi
callq 0x9700
leaq -0x140(%rbp), %rdi
callq 0x9c98
leaq -0x141(%rbp), %rdi
callq 0x9700
jmp 0x18337
movq -0x178(%rbp), %rdi
callq 0x634e0
leaq -0x48(%rbp), %rdi
callq 0x9c98
movq -0x180(%rbp), %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq -0x178(%rbp), %rdi
callq 0x634e0
leaq -0x48(%rbp), %rdi
callq 0x9c98
movq -0x58(%rbp), %rdi
callq 0x9af0
nopw %cs:(%rax,%rax)
nop