Loading src/http.cpp +15 −2 Original line number Diff line number Diff line Loading @@ -2265,8 +2265,9 @@ size_t libhttppp::HttpRequest::parseH1() { return 0; } // 2) Copy header bytes (excluding the final CRLFCRLF) header.assign(RecvData.begin(), RecvData.begin() + endpos); // 2) Copy header bytes (include the first \r\n of the separator so // every header line, including the last one, ends with \r\n) header.assign(RecvData.begin(), RecvData.begin() + endpos + 2); // 3) Consume header (and the delimiter) from RecvData endpos += 4; // include "\r\n\r\n" Loading Loading @@ -2597,6 +2598,18 @@ void libhttppp::HttpRequest::setRequestURL(const std::string &url){ void libhttppp::HttpForm::parse(libhttppp::HttpRequest &request){ if(request.getRequestType()==POSTREQUEST){ // Debug: dump all headers std::cerr << "[DEBUG HttpForm::parse] dumping headers:" << std::endl; for(auto *hd = request.getfirstHeaderData(); hd; hd = hd->nextHeaderData()){ std::cerr << " key='" << hd->getkey() << "' values:"; for(auto *v = hd->getfirstValue(); v; v = v->nextvalue()){ std::cerr << " '" << v->getvalue() << "'"; } std::cerr << std::endl; } std::cerr << "[DEBUG] RecvData.size()=" << request.RecvData.size() << " ContentLength=" << request.getContentLength() << std::endl; HttpHeader::HeaderData *ctype=request.getHeaderData("content-type"); if(!ctype){ Loading src/httpd.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -733,15 +733,22 @@ REQUESTHANDLING: break; case POSTREQUEST: { size_t clen = cureq.getContentLength(); std::cerr << "[DEBUG POST] clen=" << clen << " RecvData.size()=" << cureq.RecvData.size() << std::endl; if(clen == 0){ // No Content-Length or zero-length body: dispatch immediately // without waiting for body data std::cerr << "[DEBUG POST] clen==0, dispatching immediately" << std::endl; RequestEvent(cureq,tid,args); cureq._RequestType=PARSEREQUEST; } else if(cureq.RecvData.size()>=clen){ std::cerr << "[DEBUG POST] body complete, dispatching" << std::endl; RequestEvent(cureq,tid,args); cureq.RecvData.erase(cureq.RecvData.begin(),cureq.RecvData.begin()+clen); cureq._RequestType=PARSEREQUEST; std::cerr << "[DEBUG POST] dispatched, RequestType=PARSEREQUEST" << std::endl; } else { std::cerr << "[DEBUG POST] waiting for more body data" << std::endl; } break; } Loading Loading @@ -791,12 +798,16 @@ void libhttppp::HttpEvent::ResponseEvent(netplus::con &curcon,const int tid,ULON // partially received body to be re-parsed as HTTP headers, which // leads to an endless loop for large/multi-file uploads). if (cureq.getRequestType() == POSTREQUEST) { std::cerr << "[DEBUG RESP] skipping: still POSTREQUEST" << std::endl; return; } if (cureq.getRequestType() == PARSEREQUEST && cureq.getRequestURL().empty()) { return; } std::cerr << "[DEBUG RESP] type=" << cureq.getRequestType() << " url='" << cureq.getRequestURL() << "'" << " SendData.size()=" << cureq.SendData.size() << std::endl; ResponseEvent(cureq,tid,args); if(cureq.SendData.empty()){ cureq.SendData.pos=0; Loading Loading
src/http.cpp +15 −2 Original line number Diff line number Diff line Loading @@ -2265,8 +2265,9 @@ size_t libhttppp::HttpRequest::parseH1() { return 0; } // 2) Copy header bytes (excluding the final CRLFCRLF) header.assign(RecvData.begin(), RecvData.begin() + endpos); // 2) Copy header bytes (include the first \r\n of the separator so // every header line, including the last one, ends with \r\n) header.assign(RecvData.begin(), RecvData.begin() + endpos + 2); // 3) Consume header (and the delimiter) from RecvData endpos += 4; // include "\r\n\r\n" Loading Loading @@ -2597,6 +2598,18 @@ void libhttppp::HttpRequest::setRequestURL(const std::string &url){ void libhttppp::HttpForm::parse(libhttppp::HttpRequest &request){ if(request.getRequestType()==POSTREQUEST){ // Debug: dump all headers std::cerr << "[DEBUG HttpForm::parse] dumping headers:" << std::endl; for(auto *hd = request.getfirstHeaderData(); hd; hd = hd->nextHeaderData()){ std::cerr << " key='" << hd->getkey() << "' values:"; for(auto *v = hd->getfirstValue(); v; v = v->nextvalue()){ std::cerr << " '" << v->getvalue() << "'"; } std::cerr << std::endl; } std::cerr << "[DEBUG] RecvData.size()=" << request.RecvData.size() << " ContentLength=" << request.getContentLength() << std::endl; HttpHeader::HeaderData *ctype=request.getHeaderData("content-type"); if(!ctype){ Loading
src/httpd.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -733,15 +733,22 @@ REQUESTHANDLING: break; case POSTREQUEST: { size_t clen = cureq.getContentLength(); std::cerr << "[DEBUG POST] clen=" << clen << " RecvData.size()=" << cureq.RecvData.size() << std::endl; if(clen == 0){ // No Content-Length or zero-length body: dispatch immediately // without waiting for body data std::cerr << "[DEBUG POST] clen==0, dispatching immediately" << std::endl; RequestEvent(cureq,tid,args); cureq._RequestType=PARSEREQUEST; } else if(cureq.RecvData.size()>=clen){ std::cerr << "[DEBUG POST] body complete, dispatching" << std::endl; RequestEvent(cureq,tid,args); cureq.RecvData.erase(cureq.RecvData.begin(),cureq.RecvData.begin()+clen); cureq._RequestType=PARSEREQUEST; std::cerr << "[DEBUG POST] dispatched, RequestType=PARSEREQUEST" << std::endl; } else { std::cerr << "[DEBUG POST] waiting for more body data" << std::endl; } break; } Loading Loading @@ -791,12 +798,16 @@ void libhttppp::HttpEvent::ResponseEvent(netplus::con &curcon,const int tid,ULON // partially received body to be re-parsed as HTTP headers, which // leads to an endless loop for large/multi-file uploads). if (cureq.getRequestType() == POSTREQUEST) { std::cerr << "[DEBUG RESP] skipping: still POSTREQUEST" << std::endl; return; } if (cureq.getRequestType() == PARSEREQUEST && cureq.getRequestURL().empty()) { return; } std::cerr << "[DEBUG RESP] type=" << cureq.getRequestType() << " url='" << cureq.getRequestURL() << "'" << " SendData.size()=" << cureq.SendData.size() << std::endl; ResponseEvent(cureq,tid,args); if(cureq.SendData.empty()){ cureq.SendData.pos=0; Loading