Commit 4a4641e0 authored by jan.koester's avatar jan.koester
Browse files

test

parent 522eb344
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -2606,8 +2606,14 @@ void libhttppp::HttpForm::parse(libhttppp::HttpRequest &request){
      throw excep;
    }

    // Use content-length if available, otherwise fall back to RecvData size
    // (HTTP/2 and HTTP/3 may omit Content-Length)
    size_t bodyLen = request.getContentLength();
    if(bodyLen == 0)
      bodyLen = request.RecvData.size();

    for(auto *cval=ctype->getfirstValue(); cval; cval=cval->nextvalue()){
      if(request.getContentLength() <= request.RecvData.size()){
      if(bodyLen <= request.RecvData.size()){
        if(cval->getvalue().find("multipart/form-data") != std::string::npos){
          _contentType = "multipart/form-data";
          for(auto *cbod=ctype->getfirstValue(); cbod; cbod=cbod->nextvalue()){
@@ -2632,7 +2638,7 @@ void libhttppp::HttpForm::parse(libhttppp::HttpRequest &request){
        }
        if(cval->getvalue().find("application/x-www-form-urlencoded") != std::string::npos){
          _contentType = "application/x-www-form-urlencoded";
          _parseUrlDecode(request.RecvData.data(), request.getContentLength());
          _parseUrlDecode(request.RecvData.data(), bodyLen);
        }
      }
    }
+6 −0
Original line number Diff line number Diff line
@@ -619,6 +619,12 @@ void libhttppp::HttpEvent::Http3StreamEvent(netplus::socket *sock,
        tempreq.RecvData.append(bodyData.data(), bodyData.size());
    }

    // Ensure content-length is set from actual body size (H3 framing
    // provides the length, but application code may rely on the header)
    if (!bodyData.empty() && !tempreq.getHeaderData("content-length")) {
        tempreq.setHeaderData("content-length")->push_back(std::to_string(bodyData.size()));
    }

    // Call user's RequestEvent
    RequestEvent(tempreq, 0, 0);