wip parsing request
This commit is contained in:
@@ -241,9 +241,60 @@ int Webserv::_epoll_update(int fd, uint32_t events, int op)
|
||||
//
|
||||
void _parse_request(Client *client)
|
||||
{
|
||||
std::map<std::string, std::string> req = client->request;
|
||||
std::string request = client->raw_request;
|
||||
std::map<std::string, std::string> field = client->request;
|
||||
// size_t size = request.size();
|
||||
size_t begin = 0;
|
||||
size_t end;
|
||||
size_t len;
|
||||
|
||||
req.insert();
|
||||
// std::string str ("test un: deux\ntest deux: trois quatre\ntest :trois quatre cinq");
|
||||
// std::string sub;
|
||||
|
||||
std::cout << str << "\n\n";
|
||||
|
||||
int i = 0;
|
||||
while (end != std::string::npos)
|
||||
{
|
||||
// find first portion, before ':'
|
||||
end = str.find(':', begin);
|
||||
len = end - begin;
|
||||
if (end == std::string::npos)
|
||||
len = end;
|
||||
sub = str.substr(begin, len);
|
||||
std::cout << i << "|" << sub << "\n";
|
||||
// std::cout << "[begin:" << begin << " - end:" << end << " - len:" << len << "] " << sub << "\n";
|
||||
begin = end + 1;
|
||||
|
||||
// find second portion, until '\n'
|
||||
end = str.find('\n', begin);
|
||||
len = end - begin;
|
||||
if (end == std::string::npos)
|
||||
len = end;
|
||||
sub = str.substr(begin, len);
|
||||
std::cout << i << "|" << sub << "\n";
|
||||
begin = end + 1;
|
||||
i++;
|
||||
}
|
||||
|
||||
// for (size_t i = 0; i < size; i++)
|
||||
// {
|
||||
// field.insert(request);
|
||||
// }
|
||||
|
||||
// GET /home.html HTTP/1.1
|
||||
// Host: developer.mozilla.org
|
||||
// User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
|
||||
// Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
|
||||
// Accept-Language: en-US,en;q=0.5
|
||||
// Accept-Encoding: gzip, deflate, br
|
||||
// Referer: https://developer.mozilla.org/testpage.html
|
||||
// Connection: keep-alive
|
||||
// Upgrade-Insecure-Requests: 1
|
||||
// If-Modified-Since: Mon, 18 Jul 2016 02:36:04 GMT
|
||||
// If-None-Match: "c561c68d0ba92bbeb8b0fff2a9199f722e3a621a"
|
||||
// Cache-Control: max-age=0
|
||||
|
||||
}
|
||||
void Webserv::_serve_file(Client *client, std::string page)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user