MCPcopy Create free account
hub / github.com/XorTroll/Goldleaf / RetrieveContent

Function RetrieveContent

Goldleaf/source/net/net_Network.cpp:51–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49 }
50
51 std::string RetrieveContent(const std::string &url, const std::string &mime_type) {
52 const auto rc = socketInitializeDefault();
53 if(R_FAILED(rc)) {
54 return "";
55 }
56
57 std::string content;
58 auto curl = curl_easy_init();
59 if(!mime_type.empty()) {
60 curl_slist *header_data = nullptr;
61 header_data = curl_slist_append(header_data, ("Content-Type: " + mime_type).c_str());
62 header_data = curl_slist_append(header_data, ("Accept: " + mime_type).c_str());
63 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_data);
64 }
65 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
66 curl_easy_setopt(curl, CURLOPT_USERAGENT, "Goldleaf");
67 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0l);
68 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0l);
69 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1l);
70 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, StringWriteImpl);
71 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &content);
72 curl_easy_perform(curl);
73 curl_easy_cleanup(curl);
74 socketExit();
75 return content;
76 }
77
78 void RetrieveToFile(const std::string &url, const std::string &path, RetrieveOnProgressCallback on_progress_cb) {
79 const auto rc = socketInitializeDefault();

Callers 1

StartUpdateSearchMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected