diff options
author | sfan5 <sfan5@live.de> | 2021-04-02 00:19:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-02 00:19:39 +0200 |
commit | 34888a914e1eccce8082f45089aec17d5a2815c2 (patch) | |
tree | 31a855edf48c2cdab4da0b3e113b6a33574dfa55 /src/convert_json.cpp | |
parent | 3560691c0aecd89dc7f7d91ed8c4f1eaa9715eaf (diff) | |
download | hax-minetest-server-34888a914e1eccce8082f45089aec17d5a2815c2.tar.gz hax-minetest-server-34888a914e1eccce8082f45089aec17d5a2815c2.zip |
Sort out cURL timeouts and increase default
Diffstat (limited to 'src/convert_json.cpp')
-rw-r--r-- | src/convert_json.cpp | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/src/convert_json.cpp b/src/convert_json.cpp index e9ff1e56c..686113fa8 100644 --- a/src/convert_json.cpp +++ b/src/convert_json.cpp @@ -17,56 +17,11 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <vector> #include <iostream> #include <sstream> +#include <memory> #include "convert_json.h" -#include "content/mods.h" -#include "config.h" -#include "log.h" -#include "settings.h" -#include "httpfetch.h" -#include "porting.h" - -Json::Value fetchJsonValue(const std::string &url, - std::vector<std::string> *extra_headers) -{ - HTTPFetchRequest fetch_request; - HTTPFetchResult fetch_result; - fetch_request.url = url; - fetch_request.caller = HTTPFETCH_SYNC; - - if (extra_headers != NULL) - fetch_request.extra_headers = *extra_headers; - - httpfetch_sync(fetch_request, fetch_result); - - if (!fetch_result.succeeded) { - return Json::Value(); - } - Json::Value root; - std::istringstream stream(fetch_result.data); - - Json::CharReaderBuilder builder; - builder.settings_["collectComments"] = false; - std::string errs; - - if (!Json::parseFromStream(builder, stream, &root, &errs)) { - errorstream << "URL: " << url << std::endl; - errorstream << "Failed to parse json data " << errs << std::endl; - if (fetch_result.data.size() > 100) { - errorstream << "Data (" << fetch_result.data.size() - << " bytes) printed to warningstream." << std::endl; - warningstream << "data: \"" << fetch_result.data << "\"" << std::endl; - } else { - errorstream << "data: \"" << fetch_result.data << "\"" << std::endl; - } - return Json::Value(); - } - - return root; -} void fastWriteJson(const Json::Value &value, std::ostream &to) { |