correction of trim in case of str only fill with delim char
+ added a new split, that also does trim, to split without counting newlines
This commit is contained in:
@@ -1,29 +1,36 @@
|
||||
|
||||
#include "parsing_message_http.hpp"
|
||||
|
||||
size_t
|
||||
parse_http_first_line(std::string message, std::vector<std::string> &line)
|
||||
/*
|
||||
- parse_http_first_line() :
|
||||
- copy first line into a vector of 3 strings
|
||||
/ copy line into a vector of 3 strings
|
||||
- parse_http_headers(std::string message)
|
||||
-
|
||||
- parse_http_body(std::string message)
|
||||
*/
|
||||
|
||||
std::vector<std::string>
|
||||
parse_http_first_line(std::string line)
|
||||
{
|
||||
std::vector<std::string> sline;
|
||||
std::vector<std::string> line = "";
|
||||
std::string sub;
|
||||
std::string tmp;
|
||||
size_t pos;
|
||||
size_t ret;
|
||||
|
||||
// TODO: check for err in substr
|
||||
pos = message.find(CRLF);
|
||||
sub = message.substr(0, pos);
|
||||
sline = ::split(sub, ' ');
|
||||
ret = sline.size();
|
||||
if (ret != 3)
|
||||
return ret;
|
||||
for (int i = 0; i < 3; i++)
|
||||
sline = ::split(line, ' ');
|
||||
if (sline.size() == 3)
|
||||
{
|
||||
tmp = ::trim(sline[i], ' ');
|
||||
tmp = ::trim(tmp, '\r');
|
||||
line.push_back(tmp);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
tmp = sline[i];
|
||||
tmp = ::trim(tmp, '\r');
|
||||
tmp = ::trim(tmp, ' ');
|
||||
line.push_back(tmp);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return line;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string>
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
# include <map>
|
||||
# include "utils.hpp"
|
||||
|
||||
size_t
|
||||
parse_http_first_line(std::string message, std::vector<std::string> &line);
|
||||
std::vector<std::string>
|
||||
parse_http_first_line(std::string message);
|
||||
|
||||
std::map<std::string, std::string>
|
||||
parse_http_headers(std::string message);
|
||||
|
||||
Reference in New Issue
Block a user