diff options
author | Alexander Tkachev | 2016-05-24 11:57:49 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 826a2a921cd0b0a72f71dd6f323097a2f449fab0 (patch) | |
tree | 52df58e3cad96ada3765c6516fef10affb7aa5d7 /backends/networking/curl/curljsonrequest.cpp | |
parent | 3582f6165ce829e4990c15bf77d1792ee20dca55 (diff) | |
download | scummvm-rg350-826a2a921cd0b0a72f71dd6f323097a2f449fab0.tar.gz scummvm-rg350-826a2a921cd0b0a72f71dd6f323097a2f449fab0.tar.bz2 scummvm-rg350-826a2a921cd0b0a72f71dd6f323097a2f449fab0.zip |
CLOUD: Add DownloadRequest stub
It reads the passed NetworkReadStream and prints its contents onto
console (for now). It would be writing contents into file.
To simplify work with raw NetworkReadStream there is a new CurlRequest.
It basically does nothing, but as ConnMan handles transfers only if
there is an active Request, you need some Request to get
NetworkReadStream working. Thus, there is a CurlRequest, which is active
until NetworkReadStream is completely read. CurlRequest also has useful
addHeader() and addPostField() methods in order to customize the request
easily. Use execute() method to get its NetworkReadStream.
DropboxStorage implements streamFile() and download() API methods. As
DownloadRequest is incomplete, it is not actually downloading a file,
though.
Diffstat (limited to 'backends/networking/curl/curljsonrequest.cpp')
-rw-r--r-- | backends/networking/curl/curljsonrequest.cpp | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/backends/networking/curl/curljsonrequest.cpp b/backends/networking/curl/curljsonrequest.cpp index 805852ea0a..0366e3b403 100644 --- a/backends/networking/curl/curljsonrequest.cpp +++ b/backends/networking/curl/curljsonrequest.cpp @@ -23,7 +23,6 @@ #define FORBIDDEN_SYMBOL_ALLOW_ALL #include "backends/networking/curl/curljsonrequest.h" -#include "backends/networking/curl/connectionmanager.h" #include "backends/networking/curl/networkreadstream.h" #include "common/debug.h" #include "common/json.h" @@ -31,13 +30,10 @@ namespace Networking { -CurlJsonRequest::CurlJsonRequest(Common::BaseCallback<> *cb, const char *url): Request(cb), _stream(0), _headersList(0), _contentsStream(DisposeAfterUse::YES) { - _url = url; -} +CurlJsonRequest::CurlJsonRequest(Common::BaseCallback<> *cb, const char *url): + CurlRequest(cb, url), _contentsStream(DisposeAfterUse::YES) {} -CurlJsonRequest::~CurlJsonRequest() { - if (_stream) delete _stream; -} +CurlJsonRequest::~CurlJsonRequest() {} char *CurlJsonRequest::getPreparedContents() { //write one more byte in the end @@ -70,7 +66,7 @@ bool CurlJsonRequest::handle() { if (_stream->eos()) { if (_stream->httpResponseCode() != 200) - warning("HTTP response code is not 200 OK (it's %d)", _stream->httpResponseCode()); + warning("HTTP response code is not 200 OK (it's %ld)", _stream->httpResponseCode()); if (_callback) { char *contents = getPreparedContents(); @@ -86,16 +82,4 @@ bool CurlJsonRequest::handle() { return false; } -void CurlJsonRequest::addHeader(Common::String header) { - _headersList = curl_slist_append(_headersList, header.c_str()); -} - -void CurlJsonRequest::addPostField(Common::String keyValuePair) { - if (_postFields == "") - _postFields = keyValuePair; - else - _postFields += "&" + keyValuePair; -} - - } //end of namespace Networking |