mirror of
https://github.com/SWG-Source/src.git
synced 2026-01-17 00:04:25 -05:00
don't trust the server since it doesn't always give proper mime...
This commit is contained in:
@@ -186,7 +186,7 @@ void ClientConnection::validateClient(const std::string &id, const std::string &
|
||||
|
||||
bool done = api.setData(postData);
|
||||
if (done) {
|
||||
done = api.submit(1,1,1);
|
||||
done = api.submit(1,1);
|
||||
}
|
||||
|
||||
if (done) {
|
||||
|
||||
11
external/3rd/library/webAPI/webAPI.cpp
vendored
11
external/3rd/library/webAPI/webAPI.cpp
vendored
@@ -84,7 +84,7 @@ bool webAPI::submit(const int &reqType, const int &getPost, const int &respType)
|
||||
}
|
||||
}
|
||||
|
||||
if (fetch(getPost, respType) && !(sResponse.empty())) {
|
||||
if (fetch(getPost, reqType, respType) && !(sResponse.empty())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ bool webAPI::submit(const int &reqType, const int &getPost, const int &respType)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool webAPI::fetch(const int &getPost, const int &mimeType) // 0 for json 1 for string
|
||||
bool webAPI::fetch(const int &getPost, const int &mimeType, const int &respMimeType) // 0 for json 1 for string
|
||||
{
|
||||
bool fetchStatus = false;
|
||||
|
||||
@@ -107,12 +107,15 @@ bool webAPI::fetch(const int &getPost, const int &mimeType) // 0 for json 1 for
|
||||
|
||||
// set the content type
|
||||
if (mimeType == DTYPE::JSON) {
|
||||
slist = curl_slist_append(slist, "Accept: application/json");
|
||||
slist = curl_slist_append(slist, "Content-Type: application/json");
|
||||
} else {
|
||||
slist = curl_slist_append(slist, "Content-Type: application/x-www-form-urlencoded");
|
||||
}
|
||||
|
||||
if (respMimeType == DTYPE::JSON) {
|
||||
slist = curl_slist_append(slist, "Accept: application/json");
|
||||
}
|
||||
|
||||
slist = curl_slist_append(slist, "charsets: utf-8");
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str());
|
||||
@@ -156,7 +159,7 @@ bool webAPI::fetch(const int &getPost, const int &mimeType) // 0 for json 1 for
|
||||
if (statusCode == 200 && !(readBuffer.empty())) // check it all out and parse
|
||||
{
|
||||
sResponse = readBuffer;
|
||||
if (conType == "application/json") {
|
||||
if (conType == "application/json" || respMimeType == 0) {
|
||||
fetchStatus = processJSON();
|
||||
} else {
|
||||
responseData.clear();
|
||||
|
||||
2
external/3rd/library/webAPI/webAPI.h
vendored
2
external/3rd/library/webAPI/webAPI.h
vendored
@@ -104,7 +104,7 @@ namespace StellaBellum {
|
||||
std::string uri;
|
||||
|
||||
// fetcher - returns raw response direct from remote
|
||||
bool fetch(const int &getPost = HTTP::POST, const int &mimeType = DTYPE::JSON);
|
||||
bool fetch(const int &getPost = HTTP::POST, const int &mimeType = DTYPE::JSON, const int &respMimeType = DTYPE::JSON);
|
||||
|
||||
// cURL writeback callback
|
||||
static size_t writeCallback(void *contents, size_t size, size_t nmemb, void *userp);
|
||||
|
||||
Reference in New Issue
Block a user