Loading src/http.cpp +13 −8 Changes for src/http.cpp: 13 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -265,7 +265,7 @@ const std::vector<char> libhttppp::HttpClient::Get(libhttppp::HttpRequest &nreq) hsize=res.parse(data.data.buf,recv); recv-=++hsize; recv-=hsize; std::move(data.data.buf+hsize,data.data.buf+BLOCKSIZE,data.data.buf); Loading @@ -273,7 +273,11 @@ const std::vector<char> libhttppp::HttpClient::Get(libhttppp::HttpRequest &nreq) try{ for(libhttppp::HttpHeader::HeaderData::Values *chdat=res.getTransferEncoding(); chdat; chdat=chdat->nextvalue()){ if(chdat->getvalue()=="chunked") std::string clstr; std::transform(chdat->getvalue().begin(), chdat->getvalue().end(), clstr.begin(), [](unsigned char c){ return static_cast<char>(std::tolower(c)); } ); if(clstr=="chunked") chunked=true; } if(!chunked) Loading Loading @@ -411,7 +415,7 @@ const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq libhttppp::HttpResponse res; hsize=res.parse(data.data.buf,recv); recv-=++hsize; recv-=hsize; std::move(data.data.buf+hsize,data.data.buf+BLOCKSIZE,data.data.buf); Loading @@ -419,7 +423,11 @@ const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq try{ for(libhttppp::HttpHeader::HeaderData::Values *chdat=res.getTransferEncoding(); chdat; chdat=chdat->nextvalue()){ if(chdat->getvalue()=="chunked") std::string clstr; std::transform(chdat->getvalue().begin(), chdat->getvalue().end(), clstr.begin(), [](unsigned char c){ return static_cast<char>(std::tolower(c)); } ); if(clstr=="chunked") chunked=true; } if(!chunked) Loading @@ -428,7 +436,7 @@ const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq rlen=res.getContentLength(); } // ... (Your loop start) if(!chunked){ do{ try{ Loading @@ -440,10 +448,7 @@ const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq try{ recv=_cltsock->recvData(data); // 🚨 CRITICAL FIX: Check if recv is 0 (EOF) or less if (recv <= 0) { // If we expected more data (rlen > 0) but got EOF, // it's a premature connection close. throw netplus::NetException() [netplus::NetException::Error] << "Premature EOF while reading HTTP response body."; } Loading Loading
src/http.cpp +13 −8 Changes for src/http.cpp: 13 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -265,7 +265,7 @@ const std::vector<char> libhttppp::HttpClient::Get(libhttppp::HttpRequest &nreq) hsize=res.parse(data.data.buf,recv); recv-=++hsize; recv-=hsize; std::move(data.data.buf+hsize,data.data.buf+BLOCKSIZE,data.data.buf); Loading @@ -273,7 +273,11 @@ const std::vector<char> libhttppp::HttpClient::Get(libhttppp::HttpRequest &nreq) try{ for(libhttppp::HttpHeader::HeaderData::Values *chdat=res.getTransferEncoding(); chdat; chdat=chdat->nextvalue()){ if(chdat->getvalue()=="chunked") std::string clstr; std::transform(chdat->getvalue().begin(), chdat->getvalue().end(), clstr.begin(), [](unsigned char c){ return static_cast<char>(std::tolower(c)); } ); if(clstr=="chunked") chunked=true; } if(!chunked) Loading Loading @@ -411,7 +415,7 @@ const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq libhttppp::HttpResponse res; hsize=res.parse(data.data.buf,recv); recv-=++hsize; recv-=hsize; std::move(data.data.buf+hsize,data.data.buf+BLOCKSIZE,data.data.buf); Loading @@ -419,7 +423,11 @@ const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq try{ for(libhttppp::HttpHeader::HeaderData::Values *chdat=res.getTransferEncoding(); chdat; chdat=chdat->nextvalue()){ if(chdat->getvalue()=="chunked") std::string clstr; std::transform(chdat->getvalue().begin(), chdat->getvalue().end(), clstr.begin(), [](unsigned char c){ return static_cast<char>(std::tolower(c)); } ); if(clstr=="chunked") chunked=true; } if(!chunked) Loading @@ -428,7 +436,7 @@ const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq rlen=res.getContentLength(); } // ... (Your loop start) if(!chunked){ do{ try{ Loading @@ -440,10 +448,7 @@ const std::vector<char> libhttppp::HttpClient::Post(libhttppp::HttpRequest &nreq try{ recv=_cltsock->recvData(data); // 🚨 CRITICAL FIX: Check if recv is 0 (EOF) or less if (recv <= 0) { // If we expected more data (rlen > 0) but got EOF, // it's a premature connection close. throw netplus::NetException() [netplus::NetException::Error] << "Premature EOF while reading HTTP response body."; } Loading