added colors, for print_special

+ renamed client's public function parse_request() into parse_request_headers()
This commit is contained in:
hugogogo
2022-08-11 17:46:27 +02:00
parent ad2b5a629a
commit a1fff0f8c2
6 changed files with 35 additions and 20 deletions

View File

@@ -75,22 +75,17 @@ Client & Client::operator=( Client const & rhs )
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
// https://www.ibm.com/docs/en/cics-ts/5.3?topic=protocol-http-requests
// https://www.tutorialspoint.com/http/http_requests.htm
void Client::parse_request(std::vector<ServerConfig> &servers)
void Client::parse_request_headers(std::vector<ServerConfig> &servers)
{
clear_request(); // not mandatory
// debug
print_client("before");
_parse_request_line();
// debug
print_client("first line");
if (status)
return;
_parse_request_headers();
_parse_request_fields();
// debug
print_client("headers");
if (status)
return;
assigned_server = ::_determine_process_server(this, servers);
@@ -174,7 +169,7 @@ void Client::print_client(std::string message)
std::map<std::string, std::string>::iterator it;
std::cout << "\n=== DEBUG PRINT CLIENT ===\n";
std::cout << "\n" << message << ":\n----------\n" << "raw_request:\n__\n";
std::cout << "\n" << message << ":----------\n\n" << "raw_request:\n__\n";
::print_special(raw_request);
std::cout << "\n__\n"
<< "get_cl_fd() : [" << get_cl_fd() << "]\n"
@@ -240,12 +235,6 @@ void Client::_parse_request_line()
std::string raw_line;
raw_line = ::get_line(raw_request, 0, CRLF);
// DEBUG
std::cout << "raw_line:[";
::print_special(raw_line);
std::cout << "]\n";
line = ::split_trim(raw_line, " ");
if (line.size() != 3)
{
@@ -273,7 +262,7 @@ void Client::_parse_request_uri( std::string uri )
_request.abs_path = uri.substr(0, pos);
}
void Client::_parse_request_headers()
void Client::_parse_request_fields()
{
std::string headers;
size_t pos;