diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-10-16 04:49:14 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-10-16 04:49:14 +0200 |
commit | 221522cf995cbcd39c956f66423a26bbccae8f72 (patch) | |
tree | b09dd14964465e4d69082725d4ad950141692d8f /src/plugins | |
parent | 66a97007eb36a112f31e923c20e434ba8b39c4ba (diff) |
Matrix: stream download to rapidjson parser
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 3637d41..a0d8568 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -1730,22 +1730,12 @@ namespace QuickMedia { } DownloadResult Matrix::download_json(rapidjson::Document &result, const std::string &url, std::vector<CommandArg> additional_args, bool use_browser_useragent, std::string *err_msg) const { - std::string server_response; - if(download_to_string(url, server_response, std::move(additional_args), use_tor, use_browser_useragent, err_msg == nullptr) != DownloadResult::OK) { + if(download_to_json(url, result, std::move(additional_args), use_tor, use_browser_useragent, err_msg == nullptr) != DownloadResult::OK) { + // Cant get error since we parse directory to json. TODO: Make this work somehow? if(err_msg) - *err_msg = server_response; + *err_msg = "Failed to download/parse json"; return DownloadResult::NET_ERR; } - - rapidjson::ParseResult parse_result = result.Parse(server_response.c_str(), server_response.size()); - if(parse_result.IsError()) { - std::string error_code_str = std::to_string(parse_result.Code()); - fprintf(stderr, "download_json error: %s\n", error_code_str.c_str()); - if(err_msg) - *err_msg = "Json parse error: " + std::move(error_code_str); - return DownloadResult::ERR; - } - return DownloadResult::OK; } }
\ No newline at end of file |