Loading src/exception.cpp +8 −1 Original line number Diff line number Diff line /******************************************************************************* * Copyright (c) 2021, Jan Koester jan.koester@gmx.net c * Copyright (c) 2021, Jan Koester jan.koester@gmx.net * All rights reserved. * * Redistribution and use in source and binary forms, with or without Loading @@ -25,8 +25,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include <mutex> #include "exception.h" namespace libhttppp { std::mutex g_exception; }; libhttppp::HTTPException::HTTPException() { _curCType=HTTPException::Note; }; Loading @@ -48,6 +54,7 @@ const char* libhttppp::HTTPException::what(){ } libhttppp::HTTPException& libhttppp::HTTPException::append(const char *src){ const std::lock_guard<std::mutex> lock(g_exception); _Msg+=src; return *this; } Loading src/httpd.cpp +9 −4 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ void libhttppp::HttpEvent::RequestEvent(netplus::con* curcon){ REQUESTHANDLING: switch(cureq->getRequestType()){ case 0: std::cout.write(cureq->RecvData.data(),cureq->RecvData.size())<<std::endl; cureq->parse(); goto REQUESTHANDLING; case GETREQUEST: Loading @@ -87,11 +88,11 @@ REQUESTHANDLING: if(cureq->getContentLength()<=cureq->RecvData.size()){ RequestEvent(cureq); cureq->clear(); cureq->RecvData.resize(cureq->getContentLength()); } break; default: cureq->clear(); libhttppp::HTTPException re; re[libhttppp::HTTPException::Error] << "unknown requesttype !"; throw re; Loading @@ -107,11 +108,15 @@ void libhttppp::HttpEvent::ResponseEvent(netplus::con* curcon){ HttpRequest *cureq =(HttpRequest*)curcon; try{ ResponseEvent(cureq); if(cureq->SendData.empty()) if(cureq->SendData.empty()){ cureq->RecvData.pos=0; cureq->SendData.pos=0; cureq->clear(); } }catch(HTTPException &e){ cureq->clear(); throw e; netplus::NetException ne; ne[netplus::NetException::Error] << e.what(); throw ne; } } Loading Loading
src/exception.cpp +8 −1 Original line number Diff line number Diff line /******************************************************************************* * Copyright (c) 2021, Jan Koester jan.koester@gmx.net c * Copyright (c) 2021, Jan Koester jan.koester@gmx.net * All rights reserved. * * Redistribution and use in source and binary forms, with or without Loading @@ -25,8 +25,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include <mutex> #include "exception.h" namespace libhttppp { std::mutex g_exception; }; libhttppp::HTTPException::HTTPException() { _curCType=HTTPException::Note; }; Loading @@ -48,6 +54,7 @@ const char* libhttppp::HTTPException::what(){ } libhttppp::HTTPException& libhttppp::HTTPException::append(const char *src){ const std::lock_guard<std::mutex> lock(g_exception); _Msg+=src; return *this; } Loading
src/httpd.cpp +9 −4 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ void libhttppp::HttpEvent::RequestEvent(netplus::con* curcon){ REQUESTHANDLING: switch(cureq->getRequestType()){ case 0: std::cout.write(cureq->RecvData.data(),cureq->RecvData.size())<<std::endl; cureq->parse(); goto REQUESTHANDLING; case GETREQUEST: Loading @@ -87,11 +88,11 @@ REQUESTHANDLING: if(cureq->getContentLength()<=cureq->RecvData.size()){ RequestEvent(cureq); cureq->clear(); cureq->RecvData.resize(cureq->getContentLength()); } break; default: cureq->clear(); libhttppp::HTTPException re; re[libhttppp::HTTPException::Error] << "unknown requesttype !"; throw re; Loading @@ -107,11 +108,15 @@ void libhttppp::HttpEvent::ResponseEvent(netplus::con* curcon){ HttpRequest *cureq =(HttpRequest*)curcon; try{ ResponseEvent(cureq); if(cureq->SendData.empty()) if(cureq->SendData.empty()){ cureq->RecvData.pos=0; cureq->SendData.pos=0; cureq->clear(); } }catch(HTTPException &e){ cureq->clear(); throw e; netplus::NetException ne; ne[netplus::NetException::Error] << e.what(); throw ne; } } Loading