UI: Add request type param to GetRemoteText
parent
c4840ddba0
commit
37b9ece904
|
@ -212,7 +212,7 @@ try {
|
||||||
|
|
||||||
auto func = [&]() {
|
auto func = [&]() {
|
||||||
success = GetRemoteFile(url, output, error, nullptr,
|
success = GetRemoteFile(url, output, error, nullptr,
|
||||||
"application/x-www-form-urlencoded",
|
"application/x-www-form-urlencoded", "",
|
||||||
post_data.c_str(),
|
post_data.c_str(),
|
||||||
std::vector<std::string>(), nullptr, 5);
|
std::vector<std::string>(), nullptr, 5);
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,8 +58,8 @@ try {
|
||||||
|
|
||||||
auto func = [&]() {
|
auto func = [&]() {
|
||||||
success = GetRemoteFile(RESTREAM_STREAMKEY_URL, output, error,
|
success = GetRemoteFile(RESTREAM_STREAMKEY_URL, output, error,
|
||||||
nullptr, "application/json", nullptr,
|
nullptr, "application/json", "",
|
||||||
headers, nullptr, 5);
|
nullptr, headers, nullptr, 5);
|
||||||
};
|
};
|
||||||
|
|
||||||
ExecThreadedWithoutBlocking(
|
ExecThreadedWithoutBlocking(
|
||||||
|
|
|
@ -78,8 +78,8 @@ try {
|
||||||
auto func = [&]() {
|
auto func = [&]() {
|
||||||
success = GetRemoteFile("https://api.twitch.tv/kraken/channel",
|
success = GetRemoteFile("https://api.twitch.tv/kraken/channel",
|
||||||
output, error, &error_code,
|
output, error, &error_code,
|
||||||
"application/json", nullptr, headers,
|
"application/json", "", nullptr,
|
||||||
nullptr, 5);
|
headers, nullptr, 5);
|
||||||
};
|
};
|
||||||
|
|
||||||
ExecThreadedWithoutBlocking(
|
ExecThreadedWithoutBlocking(
|
||||||
|
|
|
@ -121,7 +121,8 @@ static size_t header_write(char *ptr, size_t size, size_t nmemb,
|
||||||
|
|
||||||
bool GetRemoteFile(const char *url, std::string &str, std::string &error,
|
bool GetRemoteFile(const char *url, std::string &str, std::string &error,
|
||||||
long *responseCode, const char *contentType,
|
long *responseCode, const char *contentType,
|
||||||
const char *postData, std::vector<std::string> extraHeaders,
|
std::string request_type, const char *postData,
|
||||||
|
std::vector<std::string> extraHeaders,
|
||||||
std::string *signature, int timeoutSec)
|
std::string *signature, int timeoutSec)
|
||||||
{
|
{
|
||||||
vector<string> header_in_list;
|
vector<string> header_in_list;
|
||||||
|
@ -178,7 +179,21 @@ bool GetRemoteFile(const char *url, std::string &str, std::string &error,
|
||||||
// A lot of servers don't yet support ALPN
|
// A lot of servers don't yet support ALPN
|
||||||
curl_easy_setopt(curl.get(), CURLOPT_SSL_ENABLE_ALPN, 0);
|
curl_easy_setopt(curl.get(), CURLOPT_SSL_ENABLE_ALPN, 0);
|
||||||
#endif
|
#endif
|
||||||
|
if (!request_type.empty()) {
|
||||||
|
if (request_type != "GET")
|
||||||
|
curl_easy_setopt(curl.get(),
|
||||||
|
CURLOPT_CUSTOMREQUEST,
|
||||||
|
request_type.c_str());
|
||||||
|
|
||||||
|
// Special case of "POST"
|
||||||
|
if (request_type == "POST") {
|
||||||
|
curl_easy_setopt(curl.get(), CURLOPT_POST, 1);
|
||||||
|
if (!postData)
|
||||||
|
curl_easy_setopt(curl.get(),
|
||||||
|
CURLOPT_POSTFIELDS,
|
||||||
|
"{}");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (postData) {
|
if (postData) {
|
||||||
curl_easy_setopt(curl.get(), CURLOPT_POSTFIELDS,
|
curl_easy_setopt(curl.get(), CURLOPT_POSTFIELDS,
|
||||||
postData);
|
postData);
|
||||||
|
|
|
@ -66,6 +66,6 @@ public:
|
||||||
bool GetRemoteFile(
|
bool GetRemoteFile(
|
||||||
const char *url, std::string &str, std::string &error,
|
const char *url, std::string &str, std::string &error,
|
||||||
long *responseCode = nullptr, const char *contentType = nullptr,
|
long *responseCode = nullptr, const char *contentType = nullptr,
|
||||||
const char *postData = nullptr,
|
std::string request_type = "", const char *postData = nullptr,
|
||||||
std::vector<std::string> extraHeaders = std::vector<std::string>(),
|
std::vector<std::string> extraHeaders = std::vector<std::string>(),
|
||||||
std::string *signature = nullptr, int timeoutSec = 0);
|
std::string *signature = nullptr, int timeoutSec = 0);
|
||||||
|
|
|
@ -370,7 +370,7 @@ try {
|
||||||
string data;
|
string data;
|
||||||
|
|
||||||
bool success = GetRemoteFile(url, data, error, &responseCode, nullptr,
|
bool success = GetRemoteFile(url, data, error, &responseCode, nullptr,
|
||||||
nullptr, extraHeaders, &signature);
|
"", nullptr, extraHeaders, &signature);
|
||||||
|
|
||||||
if (!success || (responseCode != 200 && responseCode != 304)) {
|
if (!success || (responseCode != 200 && responseCode != 304)) {
|
||||||
if (responseCode == 404)
|
if (responseCode == 404)
|
||||||
|
@ -570,7 +570,7 @@ try {
|
||||||
* get manifest from server */
|
* get manifest from server */
|
||||||
|
|
||||||
success = GetRemoteFile(WIN_MANIFEST_URL, text, error, &responseCode,
|
success = GetRemoteFile(WIN_MANIFEST_URL, text, error, &responseCode,
|
||||||
nullptr, nullptr, extraHeaders, &signature);
|
nullptr, "", nullptr, extraHeaders, &signature);
|
||||||
|
|
||||||
if (!success || (responseCode != 200 && responseCode != 304)) {
|
if (!success || (responseCode != 200 && responseCode != 304)) {
|
||||||
if (responseCode == 404)
|
if (responseCode == 404)
|
||||||
|
@ -766,7 +766,7 @@ try {
|
||||||
* get json from server */
|
* get json from server */
|
||||||
|
|
||||||
success = GetRemoteFile(WIN_WHATSNEW_URL, text, error, &responseCode,
|
success = GetRemoteFile(WIN_WHATSNEW_URL, text, error, &responseCode,
|
||||||
nullptr, nullptr, extraHeaders, &signature);
|
nullptr, "", nullptr, extraHeaders, &signature);
|
||||||
|
|
||||||
if (!success || (responseCode != 200 && responseCode != 304)) {
|
if (!success || (responseCode != 200 && responseCode != 304)) {
|
||||||
if (responseCode == 404)
|
if (responseCode == 404)
|
||||||
|
|
Loading…
Reference in New Issue