[Scummvm-git-logs] scummvm master -> 9a8aea058589d54bdba178b5737a1fbc1ed5ff72
criezy
criezy at scummvm.org
Sat Apr 29 23:14:18 CEST 2017
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9a8aea0585 CLOUD: Fix compilation with old curl vesions
Commit: 9a8aea058589d54bdba178b5737a1fbc1ed5ff72
https://github.com/scummvm/scummvm/commit/9a8aea058589d54bdba178b5737a1fbc1ed5ff72
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-04-29T22:10:16+01:00
Commit Message:
CLOUD: Fix compilation with old curl vesions
Changed paths:
backends/networking/curl/connectionmanager.cpp
backends/networking/curl/networkreadstream.cpp
backends/networking/curl/networkreadstream.h
diff --git a/backends/networking/curl/connectionmanager.cpp b/backends/networking/curl/connectionmanager.cpp
index e1761bd..d8662ab 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 4da18ce..e4fc549 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 275d8db..8e59429 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);
More information about the Scummvm-git-logs
mailing list