# include <iostream>
# include <string>
# include <sstream>

int main (int ac, char **av) {
	std::string			to_send;
	std::string			header;
	std::string			end_header = "\r\n\r\n";
	std::string			response;
	std::stringstream	strs;

	header  = "HTTP/1.1 200 OK\n";
	header += "Content-Type: text/html; charset=UTF-8\n";
	header += "Content-Length: ";

	response  =	"<!DOCTYPE html>\n";
	response +=	"<html>\n";
	response +=	"<head>\n";
	response +=		"<title>CGI</title>\n";
	response +=	"</head>\n";
	response +=	"<body>\n";
	response +=		"<h2>CGI request :</h2>\n";
	for (int i = 1; i < ac; i++)
	{
		response += "<p>";
		response += av[i];
		response += "</p>\n";
	}
	response +=	"</body>\n";
	response +=	"</html>\n";

	strs << response.size();
	header  += strs.str();
	header  += end_header;
	to_send  = header;
	to_send += response;

	std::cout << to_send;

	return 0;
}
