5 this->content = content;
6 this->contentLen = contentLen;
7 if(strstr(content,
"GET "))
14 if(strstr(content,
"POST "))
22 void HttpParser::parseGET()
24 const char *pos = strstr(content,
"GET ");
30 while((*pos ==
' ' || *pos ==
'\t') && idx < contentLen)
35 while(idx < contentLen && *pos !=
'?' && !
delimiter(*pos))
47 void HttpParser::parsePOST()
49 const char *pos = strstr(content,
"\r\n\r\n");
53 if(pos < content + contentLen)
60 void HttpParser::parse(
const char *pos)
62 size_t idx = pos - content;
63 while(idx < contentLen && !
delimiter(*pos))
71 const char *buf = pos;
72 while(*pos !=
'=' && idx < contentLen && !
delimiter(*pos))
78 var->
name = (
char*)malloc(len + 1);
85 memcpy(var->
name, buf, len);
87 var->
name[len] =
'\0';
91 while(*pos !=
'&' && idx < contentLen && !
delimiter(*pos))
97 var->
value = (
char*)malloc(len + 1);
104 memcpy(var->
value, buf, len);
106 var->
value[len] =
'\0';
108 if(idx < contentLen && *pos !=
'&')
119 for(
unsigned long i = 0; i < vars.getCount(); i++)
122 free(vars[i]->value);
129 for(
unsigned long i = 0; i < vars.getCount(); i++)
131 if(strcmp(vars[i]->
name, var) == 0)
133 return vars[i]->value;