Commit 5028d6ef authored by jan.koester's avatar jan.koester
Browse files

test

parent 4b3c1f8c
Loading
Loading
Loading
Loading
+30 −0
Changes for .gitignore: 30 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -7,3 +7,33 @@ build/
out/
.kdev4/
.kdevelop
.cache/
.idea/
*.suo
*.user
*.userosscache
*.sln.docstates
*.VC.db
*.VC.VC.opendb
ipch/
*.aps
.cache/clangd/index/client.cpp.C8A1239AF307F404.idx
.cache/clangd/index/connection_test.cpp.A43F8C46D9F50CB5.idx
.cache/clangd/index/exception.cpp.0DC893FEEF23E2B9.idx
.cache/clangd/index/exception.h.FE2BE9BCFF983ADA.idx
.cache/clangd/index/favicon_ico.h.1F9586E18EA11764.idx
.cache/clangd/index/header_png.h.05C31899EFB9BA56.idx
.cache/clangd/index/http.cpp.FD205927D803EBCE.idx
.cache/clangd/index/http.h.0AF1ED9E33926D30.idx
.cache/clangd/index/httpauth.cpp.C4964995446F0E90.idx
.cache/clangd/index/httpclient.cpp.FBE7DDCB2A25AB03.idx
.cache/clangd/index/httpcon.cpp.6BA3BC226942DB39.idx
.cache/clangd/index/httpcookie.cpp.BF330E4AA430D7B4.idx
.cache/clangd/index/httpd.cpp.65A2375954196BC5.idx
.cache/clangd/index/httpd.h.4DEB390BE8B2DCF2.idx
.cache/clangd/index/httpdefinitions.h.3CE66AEA51D0C193.idx
.cache/clangd/index/httpform.cpp.E92C5AA70CD2906A.idx
.cache/clangd/index/httphello.cpp.325C7463DD0E8165.idx
.cache/clangd/index/httpproxy.cpp.F77233150D3528DE.idx
.cache/clangd/index/httpsysinfo.cpp.8C5FFD7E6801490C.idx
.cache/clangd/index/url.cpp.A1D59345B2DBFF59.idx
+20 −11
Changes for src/http.cpp: 20 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -1421,18 +1421,14 @@ libhttppp::HttpResponse::~HttpResponse() {

}

libhttppp::HttpRequest::HttpRequest() : HttpHeader() {
libhttppp::HttpRequest::HttpRequest() : HttpHeader(), _Request(), _RequestURL(), _RequestVersion() {
  _RequestType=PARSEREQUEST;;
  _MaxUploadSize=DEFAULT_UPLOADSIZE;
  _firstHeaderData=nullptr;
  _lastHeaderData=nullptr;
};

libhttppp::HttpRequest::HttpRequest(netplus::eventapi *evapi) : con(evapi){
libhttppp::HttpRequest::HttpRequest(netplus::eventapi *evapi) : HttpHeader(), con(evapi), _Request(), _RequestURL(), _RequestVersion(){
  _RequestType=PARSEREQUEST;
  _MaxUploadSize=DEFAULT_UPLOADSIZE;
  _firstHeaderData=nullptr;
  _lastHeaderData=nullptr;
}

void libhttppp::HttpRequest::clear(){
@@ -1470,8 +1466,7 @@ size_t libhttppp::HttpRequest::parse() {
    }

    // 2) Copy header bytes (excluding the final CRLFCRLF)
    std::copy(RecvData.begin(), RecvData.begin() + endpos,
              std::inserter<std::vector<char>>(header, header.begin()));
    header.assign(RecvData.begin(), RecvData.begin() + endpos);

    // 3) Consume header (and the delimiter) from RecvData
    endpos += 4;            // include "\r\n\r\n"
@@ -1573,9 +1568,19 @@ size_t libhttppp::HttpRequest::parse() {
      size_t cr = line_start;
      while (cr < header.size() && header[cr] != '\r') ++cr;

      // bounds check: ensure we have at least \r\n
      if (cr >= header.size()) {
        // no complete line found, stop parsing
        break;
      }

      // empty line guard (shouldn't occur inside since we cut at \r\n\r\n, but just in case)
      if (cr == line_start) {
        line_start += 2; // skip "\r\n"
        if (cr + 1 < header.size()) {
          line_start = cr + 2; // skip "\r\n"
        } else {
          break;
        }
        continue;
      }

@@ -1583,10 +1588,14 @@ size_t libhttppp::HttpRequest::parse() {
      std::string hline(header.begin() + line_start, header.begin() + cr);

      // move to next line (skip "\r\n")
      if (cr + 1 < header.size() && header[cr + 1] == '\n')
      if (cr + 1 < header.size() && header[cr + 1] == '\n') {
        line_start = cr + 2;
      else
      } else if (cr + 1 == header.size()) {
        // only CR at end, no LF
        break;
      } else {
        line_start = cr + 1; // tolerant
      }

      // find delimiter ':'
      size_t colon = hline.find(':');
+5 −5
Changes for src/http.h: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -246,11 +246,11 @@ namespace libhttppp {
    void              send(const HttpUrl &dest,std::unique_ptr<netplus::socket> &sock);

  private:
    std::string       _Request;
    int               _RequestType;
    std::string       _RequestURL;
    std::string       _RequestVersion;
    size_t            _MaxUploadSize;
    std::string       _Request = std::string();
    int               _RequestType = PARSEREQUEST;
    std::string       _RequestURL = std::string();
    std::string       _RequestVersion = std::string();
    size_t            _MaxUploadSize = DEFAULT_UPLOADSIZE;
    friend class HttpForm;
    friend class HttpEvent;
  };