script output fields is checked for duplicate
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,6 +1,6 @@
|
||||
|
||||
NAME = webserv
|
||||
CXX = c++
|
||||
CXX = clang++
|
||||
|
||||
CXXFLAGS = -Wall -Wextra #-Werror
|
||||
CXXFLAGS += $(HEADERS_D:%=-I%)
|
||||
|
||||
@@ -284,6 +284,7 @@ void Client::_parse_request_fields()
|
||||
std::cerr << "err _parse_request_fields(): " << ret << " fields are bad formated\n";
|
||||
status = 400; // "bad request"
|
||||
}
|
||||
::str_map_key_tolower(_request.headers);
|
||||
}
|
||||
|
||||
void Client::_parse_port_hostname(std::string host)
|
||||
|
||||
@@ -267,7 +267,8 @@ size_t
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
key = ::str_tolower(key); // to make "key" case_insensitive
|
||||
// bad idea, in cgi we need to have the original value
|
||||
// key = ::str_tolower(key); // to make "key" case_insensitive
|
||||
val = (*it).substr(pos + 1);
|
||||
val = ::trim(val, ' ');
|
||||
fields.insert( std::pair<std::string, std::string>(key, val) );
|
||||
@@ -275,6 +276,23 @@ size_t
|
||||
return err;
|
||||
}
|
||||
|
||||
void str_map_key_tolower(std::map<std::string, std::string> & mp)
|
||||
{
|
||||
std::map<std::string, std::string> new_mp;
|
||||
std::map<std::string, std::string>::iterator it;
|
||||
std::string key;
|
||||
std::string value;
|
||||
|
||||
for (it = mp.begin(); it != mp.end(); it++)
|
||||
{
|
||||
key = it->first;
|
||||
value = it->second;
|
||||
key = ::str_tolower(key);
|
||||
new_mp.insert( std::pair<std::string, std::string>(key, value) );
|
||||
}
|
||||
mp.swap(new_mp);
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
void print_special(std::string str)
|
||||
{
|
||||
|
||||
@@ -51,6 +51,7 @@ std::string str_tolower(std::string str);
|
||||
std::string extract_line(std::string & str, size_t pos = 0, std::string delim = "\n");
|
||||
std::string get_line (std::string str, size_t pos = 0, std::string delim = "\n");
|
||||
size_t parse_http_headers (std::string headers, std::map<std::string, std::string> & fields );
|
||||
void str_map_key_tolower(std::map<std::string, std::string> & mp);
|
||||
void throw_test();
|
||||
// debug
|
||||
void print_special(std::string str);
|
||||
|
||||
@@ -198,9 +198,6 @@ for (it = scr_fld.begin(); it != scr_fld.end(); it++) {
|
||||
{
|
||||
pos = client->response.find(it_srv->first);
|
||||
::extract_line(client->response, pos, CRLF);
|
||||
// debug
|
||||
std::cout << "helloooooooooooooooooooooooooooooo\n";
|
||||
std::cout << pos << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user