diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-07-03 00:34:17 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-07-03 00:34:17 +0100 |
commit | 92a6ce11071d970ea1dacf8f25eba1b4da847c55 (patch) | |
tree | d742ba2ccdbc619b6a31b83c610c91f8ac8b9019 | |
parent | Use run over unit-test for output capture (diff) | |
download | p2pvr-92a6ce11071d970ea1dacf8f25eba1b4da847c55.tar.bz2 p2pvr-92a6ce11071d970ea1dacf8f25eba1b4da847c55.tar.xz p2pvr-92a6ce11071d970ea1dacf8f25eba1b4da847c55.zip |
Use a std::stream over a ustring for buffering json data, better with new libjsonpp interface and fixes bytes/chars bug
-rw-r--r-- | libtmdb/httpClient.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libtmdb/httpClient.cpp b/libtmdb/httpClient.cpp index 6217f1a..a4b4eb7 100644 --- a/libtmdb/httpClient.cpp +++ b/libtmdb/httpClient.cpp @@ -41,15 +41,15 @@ namespace TMDb { static size_t appendString(void * contents, size_t size, size_t nmemb, void * userp) { - auto data = static_cast<Glib::ustring *>(userp); - data->append(static_cast<const char *>(contents), size * nmemb); + auto data = static_cast<std::stringstream *>(userp); + data->write(static_cast<const char *>(contents), size * nmemb); return size * nmemb; } json::Value HttpClient::FetchJson(const std::string & path) const { - Glib::ustring jsonData; + std::stringstream jsonData; struct curl_slist *headers = NULL; curl_slist_append(headers, "Accept: application/json"); @@ -69,8 +69,7 @@ namespace TMDb { throw TMDb::HttpException(http_code); } - Glib::ustring::const_iterator itr = jsonData.begin(); - return json::parseValue(itr); + return json::parseValue(jsonData); } } |