@@ -20,14 +20,14 @@ extern "C"
2020#undef GetObject
2121#endif
2222
23- static size_t WriteCallback (void * contents, size_t size, size_t nmemb, std::vector<std::string> * userp)
23+ static size_t WriteCallback (void * contents, size_t size, size_t nmemb, std::vector<std::string>* userp)
2424{
2525 size_t totalSize = size * nmemb;
26- userp->emplace_back ((char *)contents, totalSize);
26+ userp->emplace_back ((char *)contents, totalSize);
2727 return totalSize;
2828}
2929
30- static size_t HeaderCallback (char * buffer, size_t size, size_t nitems, std::vector<std::string> * headers)
30+ static size_t HeaderCallback (char * buffer, size_t size, size_t nitems, std::vector<std::string>* headers)
3131{
3232 size_t totalSize = size * nitems;
3333 headers->emplace_back (buffer, totalSize);
@@ -50,8 +50,8 @@ void RunCurlRequest(std::string url, std::string data, std::map<std::string, std
5050{
5151 std::vector<std::string> responseBody;
5252 std::vector<std::string> responseHeaders;
53- curl_mime * mime = nullptr ;
54- CURL * curlRequest = curl_easy_init ();
53+ curl_mime* mime = nullptr ;
54+ CURL* curlRequest = curl_easy_init ();
5555 if (!curlRequest)
5656 return ;
5757
@@ -64,17 +64,17 @@ void RunCurlRequest(std::string url, std::string data, std::map<std::string, std
6464 if (headers.find (" User-Agent" ) != headers.end ())
6565 curl_easy_setopt (curlRequest, CURLOPT_USERAGENT, headers.at (" User-Agent" ).c_str ());
6666
67- struct curl_slist * headersList = nullptr ;
67+ struct curl_slist * headersList = nullptr ;
6868 for (auto it = headers.begin (); it != headers.end (); ++it)
6969 headersList = curl_slist_append (headersList, (string_format (" %s: %s" , it->first .c_str (), it->second .c_str ()) + " \0 " ).c_str ());
7070
7171 if (files.size () > 0 )
7272 {
7373 mime = curl_mime_init (curlRequest);
7474
75- for (auto & file : files)
75+ for (auto & file : files)
7676 {
77- curl_mimepart * part = curl_mime_addpart (mime);
77+ curl_mimepart* part = curl_mime_addpart (mime);
7878 curl_mime_name (part, file.first .c_str ());
7979 curl_mime_filedata (part, file.second .c_str ());
8080 }
@@ -132,10 +132,14 @@ void RunCurlRequest(std::string url, std::string data, std::map<std::string, std
132132
133133 msgpack::pack (ss, eventData);
134134
135- PluginEvent *event = new PluginEvent (" core" , nullptr , nullptr );
136- g_pluginManager->ExecuteEvent (" core" , " OnHTTPActionPerformed" , ss.str (), event);
135+ std::string eventPayload = ss.str ();
136+
137+ g_Plugin.NextFrame ([&]() -> void {
138+ PluginEvent* event = new PluginEvent (" core" , nullptr , nullptr );
139+ g_pluginManager->ExecuteEvent (" core" , " OnHTTPActionPerformed" , eventPayload, event);
140+ delete event;
141+ });
137142
138- delete event;
139143
140144 if (headersList)
141145 curl_slist_free_all (headersList);
@@ -195,7 +199,7 @@ std::string PluginHTTP::PerformHTTP(std::string receivedData)
195199
196200 std::string headerValue = headerIt->value .GetString ();
197201
198- headers.insert ({headerName, headerValue});
202+ headers.insert ({ headerName, headerValue });
199203 }
200204 }
201205 }
@@ -214,14 +218,14 @@ std::string PluginHTTP::PerformHTTP(std::string receivedData)
214218 if (!Files::ExistsPath (fileValue))
215219 continue ;
216220
217- files.insert ({fileName, fileValue});
221+ files.insert ({ fileName, fileValue });
218222 }
219223 }
220224 }
221225
222226 std::string requestUUID = get_uuid ();
223227
224- Request req = {url, data, headers, files, method, requestUUID};
228+ Request req = { url, data, headers, files, method, requestUUID };
225229 requestsQueue.push_back (req);
226230
227231 if (!httpThread)
0 commit comments