diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/networking/curl/networkreadstream.cpp | 16 | ||||
-rw-r--r-- | backends/networking/curl/networkreadstream.h | 1 |
2 files changed, 13 insertions, 4 deletions
diff --git a/backends/networking/curl/networkreadstream.cpp b/backends/networking/curl/networkreadstream.cpp index ccfb3d5a29..d761cbb5aa 100644 --- a/backends/networking/curl/networkreadstream.cpp +++ b/backends/networking/curl/networkreadstream.cpp @@ -47,11 +47,11 @@ static size_t curlHeadersCallback(char *d, size_t n, size_t l, void *p) { return 0; } -NetworkReadStream::NetworkReadStream(const char *url, curl_slist *headersList, Common::String postFields, bool uploading, bool usingPatch): - NetworkReadStream(url, headersList, (byte *)postFields.c_str(), postFields.size(), uploading, usingPatch, false) {} +void NetworkReadStream::init(const char *url, curl_slist *headersList, byte *buffer, uint32 bufferSize, bool uploading, bool usingPatch, bool post) { + _eos = _requestComplete = false; + _sendingContentsBuffer = nullptr; + _sendingContentsSize = _sendingContentsPos = 0; -NetworkReadStream::NetworkReadStream(const char *url, curl_slist *headersList, byte *buffer, uint32 bufferSize, bool uploading, bool usingPatch, bool post): - _easy(0), _eos(false), _requestComplete(false), _sendingContentsBuffer(nullptr), _sendingContentsSize(0), _sendingContentsPos(0) { _easy = curl_easy_init(); curl_easy_setopt(_easy, CURLOPT_WRITEFUNCTION, curlDataCallback); curl_easy_setopt(_easy, CURLOPT_WRITEDATA, this); //so callback can call us @@ -80,6 +80,14 @@ NetworkReadStream::NetworkReadStream(const char *url, curl_slist *headersList, b ConnMan.registerEasyHandle(_easy); } +NetworkReadStream::NetworkReadStream(const char *url, curl_slist *headersList, Common::String postFields, bool uploading, bool usingPatch) { + init(url, headersList, (byte *)postFields.c_str(), postFields.size(), uploading, usingPatch, false); +} + +NetworkReadStream::NetworkReadStream(const char *url, curl_slist *headersList, byte *buffer, uint32 bufferSize, bool uploading, bool usingPatch, bool post) { + init(url, headersList, buffer, bufferSize, uploading, usingPatch, post); +} + NetworkReadStream::~NetworkReadStream() { if (_easy) curl_easy_cleanup(_easy); diff --git a/backends/networking/curl/networkreadstream.h b/backends/networking/curl/networkreadstream.h index 991fdb346d..7a9d9ff0d1 100644 --- a/backends/networking/curl/networkreadstream.h +++ b/backends/networking/curl/networkreadstream.h @@ -39,6 +39,7 @@ class NetworkReadStream: public Common::MemoryReadWriteStream { uint32 _sendingContentsSize; uint32 _sendingContentsPos; Common::String _responseHeaders; + void init(const char *url, curl_slist *headersList, byte *buffer, uint32 bufferSize, bool uploading, bool usingPatch, bool post); public: NetworkReadStream(const char *url, curl_slist *headersList, Common::String postFields, bool uploading = false, bool usingPatch = false); |