Loading examples/httpclient.cpp +13 −12 Original line number Diff line number Diff line Loading @@ -110,17 +110,19 @@ int main(int argc, char** argv){ bool chunked=false; int rlen=0; hsize=res.parse(data,recv); hsize+=2; try { hsize=res.parse(data,len); if(strcmp(res.getTransferEncoding(),"chunked")==0){ chunklen=readchunk(data,recv,--hsize); const char *rctype=res.getTransferEncoding(); if(strcmp(rctype,"chunked")==0){ chunklen=readchunk(data,recv,hsize); chunked=true; }else{ rlen=res.getContentLength(); html.resize(rlen); } }catch(libhttppp::HTTPException &e){ std::cerr << e.what() << std::endl; }catch(...){ chunked=false; rlen=res.getContentLength(); }; if(!chunked){ Loading @@ -145,7 +147,6 @@ int main(int argc, char** argv){ } }while((chunklen=readchunk(data,recv,cpos))>0); } if(!html.empty()) std::cout << html << std::endl; return 0; }catch(netplus::NetException &exp){ Loading src/http.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <netplus/connection.h> #include <netplus/exception.h> #include <assert.h> libhttppp::HttpHeader::HttpHeader(){ _firstHeaderData=nullptr; Loading Loading @@ -100,7 +99,6 @@ const char* libhttppp::HttpHeader::getData(HttpHeader::HeaderData *pos){ if(!pos){ HTTPException httpexception; httpexception[HTTPException::Note] << "getData no valid pointer set !"; assert(0); throw httpexception; } return pos->_Value.c_str(); Loading Loading @@ -460,8 +458,6 @@ void libhttppp::HttpRequest::clear(){ _RequestVersion.clear(); } #include <iostream> size_t libhttppp::HttpRequest::parse(){ HTTPException excep; Loading Loading @@ -495,6 +491,8 @@ size_t libhttppp::HttpRequest::parse(){ std::move(RecvData.begin()+endpos,RecvData.end(),RecvData.begin()); RecvData.resize(endpos); for(size_t cpos=pos; cpos< header.size(); ++cpos){ if(header[cpos]==' '){ pos=++cpos; Loading src/httpd.cpp +5 −8 Original line number Diff line number Diff line Loading @@ -80,7 +80,6 @@ REQUESTHANDLING: case POSTREQUEST: if( cureq->RecvData.size() > cureq->getMaxUploadSize()){ cureq->clear(); cureq->RecvData.clear(); HTTPException excep; excep[HTTPException::Note] << "Upload too big increase Max Upload Size"; throw excep; Loading @@ -89,19 +88,17 @@ REQUESTHANDLING: if(cureq->getContentLength()<=cureq->RecvData.size()){ RequestEvent(cureq); cureq->clear(); if(cureq->getContentLength()==cureq->RecvData.size()){ cureq->RecvData.clear(); }else{ cureq->RecvData.resize(cureq->getContentLength()); } } break; default: break; libhttppp::HTTPException re; re[libhttppp::HTTPException::Error] << "unknown requesttype !"; throw re; } }catch(HTTPException &e){ netplus::NetException re; re[netplus::NetException::Error] << "http error:" << e.what(); re[netplus::NetException::Error] << "httpd error: " << e.what(); throw re; } } Loading Loading
examples/httpclient.cpp +13 −12 Original line number Diff line number Diff line Loading @@ -110,17 +110,19 @@ int main(int argc, char** argv){ bool chunked=false; int rlen=0; hsize=res.parse(data,recv); hsize+=2; try { hsize=res.parse(data,len); if(strcmp(res.getTransferEncoding(),"chunked")==0){ chunklen=readchunk(data,recv,--hsize); const char *rctype=res.getTransferEncoding(); if(strcmp(rctype,"chunked")==0){ chunklen=readchunk(data,recv,hsize); chunked=true; }else{ rlen=res.getContentLength(); html.resize(rlen); } }catch(libhttppp::HTTPException &e){ std::cerr << e.what() << std::endl; }catch(...){ chunked=false; rlen=res.getContentLength(); }; if(!chunked){ Loading @@ -145,7 +147,6 @@ int main(int argc, char** argv){ } }while((chunklen=readchunk(data,recv,cpos))>0); } if(!html.empty()) std::cout << html << std::endl; return 0; }catch(netplus::NetException &exp){ Loading
src/http.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <netplus/connection.h> #include <netplus/exception.h> #include <assert.h> libhttppp::HttpHeader::HttpHeader(){ _firstHeaderData=nullptr; Loading Loading @@ -100,7 +99,6 @@ const char* libhttppp::HttpHeader::getData(HttpHeader::HeaderData *pos){ if(!pos){ HTTPException httpexception; httpexception[HTTPException::Note] << "getData no valid pointer set !"; assert(0); throw httpexception; } return pos->_Value.c_str(); Loading Loading @@ -460,8 +458,6 @@ void libhttppp::HttpRequest::clear(){ _RequestVersion.clear(); } #include <iostream> size_t libhttppp::HttpRequest::parse(){ HTTPException excep; Loading Loading @@ -495,6 +491,8 @@ size_t libhttppp::HttpRequest::parse(){ std::move(RecvData.begin()+endpos,RecvData.end(),RecvData.begin()); RecvData.resize(endpos); for(size_t cpos=pos; cpos< header.size(); ++cpos){ if(header[cpos]==' '){ pos=++cpos; Loading
src/httpd.cpp +5 −8 Original line number Diff line number Diff line Loading @@ -80,7 +80,6 @@ REQUESTHANDLING: case POSTREQUEST: if( cureq->RecvData.size() > cureq->getMaxUploadSize()){ cureq->clear(); cureq->RecvData.clear(); HTTPException excep; excep[HTTPException::Note] << "Upload too big increase Max Upload Size"; throw excep; Loading @@ -89,19 +88,17 @@ REQUESTHANDLING: if(cureq->getContentLength()<=cureq->RecvData.size()){ RequestEvent(cureq); cureq->clear(); if(cureq->getContentLength()==cureq->RecvData.size()){ cureq->RecvData.clear(); }else{ cureq->RecvData.resize(cureq->getContentLength()); } } break; default: break; libhttppp::HTTPException re; re[libhttppp::HTTPException::Error] << "unknown requesttype !"; throw re; } }catch(HTTPException &e){ netplus::NetException re; re[netplus::NetException::Error] << "http error:" << e.what(); re[netplus::NetException::Error] << "httpd error: " << e.what(); throw re; } } Loading