2024年2月14日发(作者:郜安吉)
bool UpdateTask::fetchUpdateInfoFromHTTPServer(){ //请求的参数 std::string arg1 = "1"; std::string arg2 = "2"; std::string arg3 = "3"; //拼接对应的请求 Config config; std::string path = "/api/v1/update"; Poco::URI uri; eme(verScheme()); t(verAddr()); t(verPort()); h(path); ryParameter("arg1", arg1); ryParameter("arg2", arg2); ryParameter("arg3", arg3); Poco::Net::HTTPSClientSession* https_session = OSUtils::CommonUtils::GetHttpsClientSession(); https_session->setPort(t()); https_session->setHost(t()); std::string pathAndQuery(hAndQuery());
Poco::Net::HTTPRequest request( Poco::Net::HTTPRequest::HTTP_GET, pathAndQuery, Poco::Net::HTTPMessage::HTTP_1_1); Poco::Net::HTTPResponse response; https_session->sendRequest(request); std::istream &streamIn = https_session->receiveResponse(response); std::ostringstream responseStream; Poco::StreamCopier::copyStream(streamIn, responseStream); m_responseContent = (); delete https_session; https_session = nullptr; return tus() == Poco::Net::HTTPResponse::HTTP_OK;}HTTP POST下载请求int MyUpdateTask::UpdateWork(std::string loginid, std::string clientid, std::string& filePath){ try { Config config; std::string path = "/api/v1/dict/download"; Poco::URI uri; eme(verScheme()); t(verAddr()); t(verPort()); h(path); Poco::Net::HTTPSClientSession* https_session = OSUtils::CommonUtils::GetHttpsClientSession(); https_session->setHost(t()); https_session->setPort(t()); Poco::Net::HTTPRequest request( Poco::Net::HTTPRequest::HTTP_POST, hAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
Poco::Net::HTMLForm form; ("loginid", loginid); ("clientid", clientid); eSubmit(request); (https_session->sendRequest(request)); Poco::Net::HTTPResponse response; std::istream &streamIn = https_session->receiveResponse(response);
if (tus() != Poco::Net::HTTPResponse::HTTP_OK) { delete https_session; https_session = nullptr; return 1; } std::ostringstream responseStream; Poco::StreamCopier::copyStream(streamIn, responseStream); std::string resultStr = (); delete https_session; https_session = nullptr; Poco::JSON::Parser parser; auto root = (resultStr); Poco::JSON::Object::Ptr objRoot = t
dictFilePath = objRoot->getValue
2024年2月14日发(作者:郜安吉)
bool UpdateTask::fetchUpdateInfoFromHTTPServer(){ //请求的参数 std::string arg1 = "1"; std::string arg2 = "2"; std::string arg3 = "3"; //拼接对应的请求 Config config; std::string path = "/api/v1/update"; Poco::URI uri; eme(verScheme()); t(verAddr()); t(verPort()); h(path); ryParameter("arg1", arg1); ryParameter("arg2", arg2); ryParameter("arg3", arg3); Poco::Net::HTTPSClientSession* https_session = OSUtils::CommonUtils::GetHttpsClientSession(); https_session->setPort(t()); https_session->setHost(t()); std::string pathAndQuery(hAndQuery());
Poco::Net::HTTPRequest request( Poco::Net::HTTPRequest::HTTP_GET, pathAndQuery, Poco::Net::HTTPMessage::HTTP_1_1); Poco::Net::HTTPResponse response; https_session->sendRequest(request); std::istream &streamIn = https_session->receiveResponse(response); std::ostringstream responseStream; Poco::StreamCopier::copyStream(streamIn, responseStream); m_responseContent = (); delete https_session; https_session = nullptr; return tus() == Poco::Net::HTTPResponse::HTTP_OK;}HTTP POST下载请求int MyUpdateTask::UpdateWork(std::string loginid, std::string clientid, std::string& filePath){ try { Config config; std::string path = "/api/v1/dict/download"; Poco::URI uri; eme(verScheme()); t(verAddr()); t(verPort()); h(path); Poco::Net::HTTPSClientSession* https_session = OSUtils::CommonUtils::GetHttpsClientSession(); https_session->setHost(t()); https_session->setPort(t()); Poco::Net::HTTPRequest request( Poco::Net::HTTPRequest::HTTP_POST, hAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
Poco::Net::HTMLForm form; ("loginid", loginid); ("clientid", clientid); eSubmit(request); (https_session->sendRequest(request)); Poco::Net::HTTPResponse response; std::istream &streamIn = https_session->receiveResponse(response);
if (tus() != Poco::Net::HTTPResponse::HTTP_OK) { delete https_session; https_session = nullptr; return 1; } std::ostringstream responseStream; Poco::StreamCopier::copyStream(streamIn, responseStream); std::string resultStr = (); delete https_session; https_session = nullptr; Poco::JSON::Parser parser; auto root = (resultStr); Poco::JSON::Object::Ptr objRoot = t
dictFilePath = objRoot->getValue