Nu met extra puddingbroodjes!

This commit is contained in:
Thulinma 2011-02-12 15:52:36 +01:00
parent 17b3de7791
commit 97ac154337
2 changed files with 3 additions and 1 deletions

View file

@ -41,6 +41,7 @@ int mainHandler(int CONN_fd){
retval = epoll_wait(poller, events, 1, 1); retval = epoll_wait(poller, events, 1, 1);
if ((retval > 0) || !ready4data){ if ((retval > 0) || !ready4data){
if (HTTP_R.ReadSocket(CONN_fd)){ if (HTTP_R.ReadSocket(CONN_fd)){
printf("Puddingbroodjes!\n");
//ERIK: we hebben nu een hele HTTP request geparsed - verwerken mag hier, door aanroepen naar //ERIK: we hebben nu een hele HTTP request geparsed - verwerken mag hier, door aanroepen naar
//ERIK: bijvoorbeeld HTTP_R.GetHeader("headernaam") (voor headers) of HTTP_R.GetVar("varnaam") (voor GET/POST vars) //ERIK: bijvoorbeeld HTTP_R.GetHeader("headernaam") (voor headers) of HTTP_R.GetVar("varnaam") (voor GET/POST vars)
//ERIK: of HTTP_R.method of HTTP_R.url of HTTP_R.protocol.... //ERIK: of HTTP_R.method of HTTP_R.url of HTTP_R.protocol....

View file

@ -136,6 +136,7 @@ bool HTTPReader::parse(){
if (f == std::string::npos) return false; if (f == std::string::npos) return false;
tmpA = HTTPbuffer.substr(0, f); tmpA = HTTPbuffer.substr(0, f);
HTTPbuffer.erase(0, f+1); HTTPbuffer.erase(0, f+1);
while (tmpA.find('\r') != std::string::npos){tmpA.erase(tmpA.find('\r'));}
if (!seenReq){ if (!seenReq){
seenReq = true; seenReq = true;
f = tmpA.find(' '); f = tmpA.find(' ');
@ -146,7 +147,7 @@ bool HTTPReader::parse(){
if (f != std::string::npos){protocol = tmpA.substr(0, f); tmpA.erase(0, f+1);} if (f != std::string::npos){protocol = tmpA.substr(0, f); tmpA.erase(0, f+1);}
//TODO: GET variable parsing //TODO: GET variable parsing
}else{ }else{
if (tmpA[0] == '\n'){ if (tmpA.size() == 0){
seenHeaders = true; seenHeaders = true;
if (GetHeader("Content-Length") != ""){length = atoi(GetHeader("Content-Length").c_str());} if (GetHeader("Content-Length") != ""){length = atoi(GetHeader("Content-Length").c_str());}
}else{ }else{