aboutsummaryrefslogtreecommitdiff
path: root/backends/networking
diff options
context:
space:
mode:
Diffstat (limited to 'backends/networking')
-rw-r--r--backends/networking/curl/connectionmanager.cpp2
-rw-r--r--backends/networking/curl/curljsonrequest.cpp9
-rw-r--r--backends/networking/curl/curljsonrequest.h3
-rw-r--r--backends/networking/curl/curlrequest.cpp7
-rw-r--r--backends/networking/curl/curlrequest.h8
5 files changed, 24 insertions, 5 deletions
diff --git a/backends/networking/curl/connectionmanager.cpp b/backends/networking/curl/connectionmanager.cpp
index b448d8e514..77a46ec518 100644
--- a/backends/networking/curl/connectionmanager.cpp
+++ b/backends/networking/curl/connectionmanager.cpp
@@ -76,6 +76,7 @@ void ConnectionManager::startTimer(int interval) {
}
void ConnectionManager::stopTimer() {
+ debug("timer stopped");
Common::TimerManager *manager = g_system->getTimerManager();
manager->removeTimerProc(connectionsThread);
_timerStarted = false;
@@ -111,6 +112,7 @@ void ConnectionManager::interateRequests() {
else {
info.state = PROCESSING;
info.request->restart();
+ debug("request restarted");
}
default:
diff --git a/backends/networking/curl/curljsonrequest.cpp b/backends/networking/curl/curljsonrequest.cpp
index a323b34ed2..1231f9e7e8 100644
--- a/backends/networking/curl/curljsonrequest.cpp
+++ b/backends/networking/curl/curljsonrequest.cpp
@@ -74,11 +74,18 @@ void CurlJsonRequest::handle() {
char *contents = getPreparedContents();
if (_stream->httpResponseCode() != 200)
debug("%s", contents);
- Common::JSONValue *json = Common::JSON::parse(contents);
+ Common::JSONValue *json = Common::JSON::parse(contents);
(*_jsonCallback)(RequestJsonPair(_id, json)); //potential memory leak, free it in your callbacks!
}
}
}
}
+void CurlJsonRequest::restart() {
+ if (_stream) delete _stream;
+ _stream = 0;
+ _contentsStream = Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES);
+ //with no stream available next handle() will create another one
+}
+
} //end of namespace Networking
diff --git a/backends/networking/curl/curljsonrequest.h b/backends/networking/curl/curljsonrequest.h
index 75d4a6df81..af19ec3596 100644
--- a/backends/networking/curl/curljsonrequest.h
+++ b/backends/networking/curl/curljsonrequest.h
@@ -45,7 +45,8 @@ public:
CurlJsonRequest(JsonCallback cb, const char *url);
virtual ~CurlJsonRequest();
- virtual void handle();
+ virtual void handle();
+ virtual void restart();
};
} //end of namespace Networking
diff --git a/backends/networking/curl/curlrequest.cpp b/backends/networking/curl/curlrequest.cpp
index e30b7ce018..1b42ac5931 100644
--- a/backends/networking/curl/curlrequest.cpp
+++ b/backends/networking/curl/curlrequest.cpp
@@ -53,6 +53,13 @@ void CurlRequest::restart() {
//with no stream available next handle() will create another one
}
+void CurlRequest::setHeaders(Common::Array<Common::String> &headers) {
+ curl_slist_free_all(_headersList);
+ _headersList = 0;
+ for (uint32 i = 0; i < headers.size(); ++i)
+ addHeader(headers[i]);
+}
+
void CurlRequest::addHeader(Common::String header) {
_headersList = curl_slist_append(_headersList, header.c_str());
}
diff --git a/backends/networking/curl/curlrequest.h b/backends/networking/curl/curlrequest.h
index 1a644e4369..c624194142 100644
--- a/backends/networking/curl/curlrequest.h
+++ b/backends/networking/curl/curlrequest.h
@@ -25,6 +25,7 @@
#include "backends/networking/curl/request.h"
#include "common/str.h"
+#include <common/array.h>
struct curl_slist;
@@ -46,11 +47,12 @@ public:
virtual void handle();
virtual void restart();
- void addHeader(Common::String header);
- void addPostField(Common::String header);
+ virtual void setHeaders(Common::Array<Common::String> &headers);
+ virtual void addHeader(Common::String header);
+ virtual void addPostField(Common::String field);
/** Start this Request with ConnMan. Returns its ReadStream. */
- NetworkReadStream *execute();
+ virtual NetworkReadStream *execute();
};
} //end of namespace Networking