// File: /workspace/github_cpp_makefile_star2_O2/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
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rdx, %r15
movq %rdi, %rbx
movb $0x0, (%rax)
addq $0xb8, %r15
movl $0xc8, %esi
movq %r15, %rdx
callq 0x2a080
leaq 0x1f512(%rip), %rsi     # 0x2c7c7
movq %r15, %rdi
callq 0x91b7
testb %al, %al
je 0xd3d0
leaq 0x1f4fd(%rip), %rsi     # 0x2c7c9
leaq 0x48(%rsp), %rdi
callq 0x7930
leaq 0x1edc6(%rip), %rsi     # 0x2c0a3
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x8032
leaq 0x8(%rsp), %rsi
leaq 0x48(%rsp), %rdx
movq %rbx, %rdi
callq 0x2a124
leaq 0x8(%rsp), %rdi
callq 0x79b8
movq %rbx, %rdi
callq 0x2a2f0
leaq 0x1ef35(%rip), %rsi     # 0x2c24c
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x8032
leaq 0x1f863(%rip), %rsi     # 0x2cb90
leaq 0x28(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x8032
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x2a124
leaq 0x28(%rsp), %rdi
callq 0x79b8
leaq 0x8(%rsp), %rdi
callq 0x79b8
leaq 0x1ed9b(%rip), %rsi     # 0x2c104
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x8032
leaq 0x1fe50(%rip), %rsi     # 0x2d1cf
leaq 0x28(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x8032
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x2a124
leaq 0x28(%rsp), %rdi
callq 0x79b8
leaq 0x8(%rsp), %rdi
callq 0x79b8
leaq 0x48(%rsp), %rdi
callq 0x79b8
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x2166a
movq %rax, %r14
leaq 0x8(%rsp), %r15
leaq 0x48(%rsp), %r12
leaq 0x1f413(%rip), %r13     # 0x2c7ff
movq %rax, %rbp
movq (%rbp), %rbp
cmpq %r14, %rbp
je 0xd2d6
cmpq (%r14), %rbp
je 0xd40c
movq %r12, %rdi
movq %r13, %rsi
callq 0x7920
movq 0x10(%rbp), %rsi
movq (%rsi), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq %r12, %rdi
movq %r15, %rsi
callq 0x7950
movq %r15, %rdi
callq 0x79b8
jmp 0xd3ef
jmp 0xd456
jmp 0xd436
jmp 0xd45b
jmp 0xd456
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x79b8
jmp 0xd45e
jmp 0xd45b
jmp 0xd456
jmp 0xd45b
jmp 0xd456
movq %rax, %r14
jmp 0xd470
jmp 0xd456
jmp 0xd456
movq %rax, %r14
jmp 0xd468
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x79b8
movq %rbx, %rdi
callq 0x29f10
leaq 0x48(%rsp), %rdi
callq 0x79b8
movq %r14, %rdi
callq 0x7860
nop