diff options
author | ShadowNinja <shadowninja@minetest.net> | 2014-09-14 20:46:45 -0400 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-09-18 21:54:22 -0400 |
commit | 86a3c8ce566f28112dc032aa48c40e12fde97be2 (patch) | |
tree | 26b688e66efb45803081537023461c57991ef049 /src/convert_json.cpp | |
parent | 18bfa1c785a123499ee12d0551a9447a4d32d93b (diff) | |
download | minetest-86a3c8ce566f28112dc032aa48c40e12fde97be2.tar.gz minetest-86a3c8ce566f28112dc032aa48c40e12fde97be2.tar.bz2 minetest-86a3c8ce566f28112dc032aa48c40e12fde97be2.zip |
Reduce indentation of HTTPFetchOngoing
Also clean up some related things.
Diffstat (limited to 'src/convert_json.cpp')
-rw-r--r-- | src/convert_json.cpp | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/src/convert_json.cpp b/src/convert_json.cpp index c5c69d93c..cea089623 100644 --- a/src/convert_json.cpp +++ b/src/convert_json.cpp @@ -30,45 +30,34 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "httpfetch.h" #include "porting.h" -Json::Value fetchJsonValue(const std::string &url, - std::vector<std::string> *extra_headers) { - - HTTPFetchRequest fetchrequest; - HTTPFetchResult fetchresult; - fetchrequest.url = url; - fetchrequest.caller = HTTPFETCH_SYNC; +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) - fetchrequest.extra_headers = *extra_headers; + fetch_request.extra_headers = *extra_headers; - httpfetch_sync(fetchrequest,fetchresult); + httpfetch_sync(fetch_request, fetch_result); - if (!fetchresult.succeeded) { + if (!fetch_result.succeeded) { return Json::Value(); } Json::Value root; Json::Reader reader; - std::istringstream stream(fetchresult.data); + std::istringstream stream(fetch_result.data); - if (!reader.parse( stream, root ) ) - { + if (!reader.parse(stream, root)) { errorstream << "URL: " << url << std::endl; errorstream << "Failed to parse json data " << reader.getFormattedErrorMessages(); - errorstream << "data: \"" << fetchresult.data << "\"" << std::endl; + errorstream << "data: \"" << fetch_result.data << "\"" << std::endl; return Json::Value(); } - if (root.isArray()) { - return root; - } - if ((root["list"].isArray())) { - return root["list"]; - } - else { - return root; - } - - return Json::Value(); + return root; } std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) { |