aboutsummaryrefslogtreecommitdiff
path: root/backends/networking
diff options
context:
space:
mode:
authorThierry Crozat2017-04-29 22:09:13 +0100
committerThierry Crozat2017-04-29 22:10:16 +0100
commit9a8aea058589d54bdba178b5737a1fbc1ed5ff72 (patch)
tree0523e8178eca62bb640dddd6851e9aac5b7e1c6b /backends/networking
parenta4e504111775158d93a2aeec44814fe7e106dab6 (diff)
downloadscummvm-rg350-9a8aea058589d54bdba178b5737a1fbc1ed5ff72.tar.gz
scummvm-rg350-9a8aea058589d54bdba178b5737a1fbc1ed5ff72.tar.bz2
scummvm-rg350-9a8aea058589d54bdba178b5737a1fbc1ed5ff72.zip
CLOUD: Fix compilation with old curl vesions
Diffstat (limited to 'backends/networking')
-rw-r--r--backends/networking/curl/connectionmanager.cpp4
-rw-r--r--backends/networking/curl/networkreadstream.cpp10
-rw-r--r--backends/networking/curl/networkreadstream.h1
3 files changed, 15 insertions, 0 deletions
diff --git a/backends/networking/curl/connectionmanager.cpp b/backends/networking/curl/connectionmanager.cpp
index e1761bddc6..d8662ab78d 100644
--- a/backends/networking/curl/connectionmanager.cpp
+++ b/backends/networking/curl/connectionmanager.cpp
@@ -81,7 +81,11 @@ Request *ConnectionManager::addRequest(Request *request, RequestCallback callbac
Common::String ConnectionManager::urlEncode(Common::String s) const {
if (!_multi)
return "";
+#if LIBCURL_VERSION_NUM >= 0x070F04
char *output = curl_easy_escape(_multi, s.c_str(), s.size());
+#else
+ char *output = curl_escape(s.c_str(), s.size());
+#endif
if (output) {
Common::String result = output;
curl_free(output);
diff --git a/backends/networking/curl/networkreadstream.cpp b/backends/networking/curl/networkreadstream.cpp
index 4da18ce311..e4fc5492b5 100644
--- a/backends/networking/curl/networkreadstream.cpp
+++ b/backends/networking/curl/networkreadstream.cpp
@@ -67,6 +67,7 @@ void NetworkReadStream::init(const char *url, curl_slist *headersList, const byt
_sendingContentsBuffer = nullptr;
_sendingContentsSize = _sendingContentsPos = 0;
_progressDownloaded = _progressTotal = 0;
+ _bufferCopy = nullptr;
_easy = curl_easy_init();
curl_easy_setopt(_easy, CURLOPT_WRITEFUNCTION, curlDataCallback);
@@ -100,7 +101,14 @@ void NetworkReadStream::init(const char *url, curl_slist *headersList, const byt
} else {
if (post || bufferSize != 0) {
curl_easy_setopt(_easy, CURLOPT_POSTFIELDSIZE, bufferSize);
+#if LIBCURL_VERSION_NUM >= 0x071101
+ // CURLOPT_COPYPOSTFIELDS available since curl 7.17.1
curl_easy_setopt(_easy, CURLOPT_COPYPOSTFIELDS, buffer);
+#else
+ _bufferCopy = (byte*)malloc(bufferSize);
+ memcpy(_bufferCopy, buffer, bufferSize);
+ curl_easy_setopt(_easy, CURLOPT_POSTFIELDS, _bufferCopy);
+#endif
}
}
ConnMan.registerEasyHandle(_easy);
@@ -111,6 +119,7 @@ void NetworkReadStream::init(const char *url, curl_slist *headersList, Common::H
_sendingContentsBuffer = nullptr;
_sendingContentsSize = _sendingContentsPos = 0;
_progressDownloaded = _progressTotal = 0;
+ _bufferCopy = nullptr;
_easy = curl_easy_init();
curl_easy_setopt(_easy, CURLOPT_WRITEFUNCTION, curlDataCallback);
@@ -184,6 +193,7 @@ NetworkReadStream::NetworkReadStream(const char *url, curl_slist *headersList, c
NetworkReadStream::~NetworkReadStream() {
if (_easy)
curl_easy_cleanup(_easy);
+ free(_bufferCopy);
}
bool NetworkReadStream::eos() const {
diff --git a/backends/networking/curl/networkreadstream.h b/backends/networking/curl/networkreadstream.h
index 275d8dbd79..8e59429a0a 100644
--- a/backends/networking/curl/networkreadstream.h
+++ b/backends/networking/curl/networkreadstream.h
@@ -40,6 +40,7 @@ class NetworkReadStream: public Common::MemoryReadWriteStream {
const byte *_sendingContentsBuffer;
uint32 _sendingContentsSize;
uint32 _sendingContentsPos;
+ byte* _bufferCopy; // To use with old curl version where CURLOPT_COPYPOSTFIELDS is not available
Common::String _responseHeaders;
uint64 _progressDownloaded, _progressTotal;
void init(const char *url, curl_slist *headersList, const byte *buffer, uint32 bufferSize, bool uploading, bool usingPatch, bool post);