Loading examples/httpclient.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -81,10 +81,10 @@ size_t readchunk(const char *data,size_t datasize,size_t &pos){ int main(int argc, char** argv){ signal(SIGPIPE, SIG_IGN); netplus::tcp cltsock; netplus::tcp srvsock(argv[1],atoi(argv[2]),1,0); std::shared_ptr<netplus::tcp> cltsock=std::make_shared<netplus::tcp>(); std::shared_ptr<netplus::tcp> srvsock=std::make_shared<netplus::tcp>(argv[1],atoi(argv[2]),1,0); try{ srvsock.connect(cltsock); srvsock->connect(cltsock); try{ libhttppp::HttpRequest req; Loading @@ -102,7 +102,7 @@ int main(int argc, char** argv){ } char data[16384]; size_t recv=srvsock.recvData(cltsock,data,16384); size_t recv=srvsock->recvData(cltsock,data,16384); std::string html; libhttppp::HttpResponse res; Loading @@ -128,7 +128,7 @@ int main(int argc, char** argv){ html.append(data+hsize,recv-hsize); rlen-=recv-hsize; if(rlen>0){ recv=srvsock.recvData(cltsock,data,16384); recv=srvsock->recvData(cltsock,data,16384); hsize=0; } }while(rlen>0); Loading src/http.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -646,15 +646,15 @@ void libhttppp::HttpRequest::setRequestVersion(const char* version){ } void libhttppp::HttpRequest::send(netplus::socket& src,netplus::socket& dest){ void libhttppp::HttpRequest::send(std::shared_ptr<netplus::socket> src,std::shared_ptr<netplus::socket> dest){ std::string header; printHeader(header); try { size_t send=dest.sendData(src,(void*)header.c_str(),header.length()); size_t send=dest->sendData(src,(void*)header.c_str(),header.length()); while(send<_Request.length()){ send+=dest.sendData(src,(void*)_Request.substr(send,_Request.length()-send).c_str(), send+=dest->sendData(src,(void*)_Request.substr(send,_Request.length()-send).c_str(), _Request.length()-send); } }catch(netplus::NetException &e){ Loading src/http.h +3 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stddef.h> #include <sys/types.h> #include <memory> #include <string> #include <netplus/eventapi.h> Loading Loading @@ -141,7 +142,7 @@ namespace libhttppp { void setRequestVersion(const char *version); /*only for post Reuquesttype*/ void setRequestData(const char *data,size_t len); void send(netplus::socket& src,netplus::socket& dest); void send(std::shared_ptr<netplus::socket> src,std::shared_ptr<netplus::socket> dest); private: std::string _Request; int _RequestType; Loading src/httpd.cpp +0 −4 Original line number Diff line number Diff line Loading @@ -83,15 +83,11 @@ libhttppp::HttpD::HttpD(int argc, char** argv){ const char *sslcertpath = nullptr; if (HTTPDCmdController->getCmdbyKey("httpscert")) sslcertpath = HTTPDCmdController->getCmdbyKey("httpscert")->getValue(); else sslcertpath = nullptr; /*get httpaddress from console paramter*/ const char *sslkeypath = nullptr; if (HTTPDCmdController->getCmdbyKey("httpskey")) sslkeypath = HTTPDCmdController->getCmdbyKey("httpskey")->getValue(); else sslkeypath = nullptr; try { if (sslcertpath && sslkeypath) { Loading Loading
examples/httpclient.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -81,10 +81,10 @@ size_t readchunk(const char *data,size_t datasize,size_t &pos){ int main(int argc, char** argv){ signal(SIGPIPE, SIG_IGN); netplus::tcp cltsock; netplus::tcp srvsock(argv[1],atoi(argv[2]),1,0); std::shared_ptr<netplus::tcp> cltsock=std::make_shared<netplus::tcp>(); std::shared_ptr<netplus::tcp> srvsock=std::make_shared<netplus::tcp>(argv[1],atoi(argv[2]),1,0); try{ srvsock.connect(cltsock); srvsock->connect(cltsock); try{ libhttppp::HttpRequest req; Loading @@ -102,7 +102,7 @@ int main(int argc, char** argv){ } char data[16384]; size_t recv=srvsock.recvData(cltsock,data,16384); size_t recv=srvsock->recvData(cltsock,data,16384); std::string html; libhttppp::HttpResponse res; Loading @@ -128,7 +128,7 @@ int main(int argc, char** argv){ html.append(data+hsize,recv-hsize); rlen-=recv-hsize; if(rlen>0){ recv=srvsock.recvData(cltsock,data,16384); recv=srvsock->recvData(cltsock,data,16384); hsize=0; } }while(rlen>0); Loading
src/http.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -646,15 +646,15 @@ void libhttppp::HttpRequest::setRequestVersion(const char* version){ } void libhttppp::HttpRequest::send(netplus::socket& src,netplus::socket& dest){ void libhttppp::HttpRequest::send(std::shared_ptr<netplus::socket> src,std::shared_ptr<netplus::socket> dest){ std::string header; printHeader(header); try { size_t send=dest.sendData(src,(void*)header.c_str(),header.length()); size_t send=dest->sendData(src,(void*)header.c_str(),header.length()); while(send<_Request.length()){ send+=dest.sendData(src,(void*)_Request.substr(send,_Request.length()-send).c_str(), send+=dest->sendData(src,(void*)_Request.substr(send,_Request.length()-send).c_str(), _Request.length()-send); } }catch(netplus::NetException &e){ Loading
src/http.h +3 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stddef.h> #include <sys/types.h> #include <memory> #include <string> #include <netplus/eventapi.h> Loading Loading @@ -141,7 +142,7 @@ namespace libhttppp { void setRequestVersion(const char *version); /*only for post Reuquesttype*/ void setRequestData(const char *data,size_t len); void send(netplus::socket& src,netplus::socket& dest); void send(std::shared_ptr<netplus::socket> src,std::shared_ptr<netplus::socket> dest); private: std::string _Request; int _RequestType; Loading
src/httpd.cpp +0 −4 Original line number Diff line number Diff line Loading @@ -83,15 +83,11 @@ libhttppp::HttpD::HttpD(int argc, char** argv){ const char *sslcertpath = nullptr; if (HTTPDCmdController->getCmdbyKey("httpscert")) sslcertpath = HTTPDCmdController->getCmdbyKey("httpscert")->getValue(); else sslcertpath = nullptr; /*get httpaddress from console paramter*/ const char *sslkeypath = nullptr; if (HTTPDCmdController->getCmdbyKey("httpskey")) sslkeypath = HTTPDCmdController->getCmdbyKey("httpskey")->getValue(); else sslkeypath = nullptr; try { if (sslcertpath && sslkeypath) { Loading