summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/components/http/httpdelete.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/components/http/httpdelete.cpp')
-rw-r--r--sca-cpp/trunk/components/http/httpdelete.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/sca-cpp/trunk/components/http/httpdelete.cpp b/sca-cpp/trunk/components/http/httpdelete.cpp
index d78a4d60df..c725461ec2 100644
--- a/sca-cpp/trunk/components/http/httpdelete.cpp
+++ b/sca-cpp/trunk/components/http/httpdelete.cpp
@@ -37,7 +37,7 @@ namespace httpdelete {
/**
* Evaluate an HTTP delete.
*/
-const failable<value> get(const lambda<value(const list<value>&)> url, http::CURLSession& ch) {
+const failable<value> get(const lambda<value(const list<value>&)>& url, http::CURLSession& ch) {
debug("httpdelete::get");
const value u = url(mklist<value>("get", list<value>()));
debug(u, "httpdelete::get::url");
@@ -49,7 +49,7 @@ const failable<value> get(const lambda<value(const list<value>&)> url, http::CUR
*/
class applyhttp {
public:
- applyhttp(const lambda<value(const list<value>&)> url, const perthread_ptr<http::CURLSession>& ch) : url(url), ch(ch) {
+ applyhttp(const lambda<value(const list<value>&)>& url, const perthread_ptr<http::CURLSession>& ch) : url(url), ch(ch) {
}
const value operator()(const list<value>& params) const {
@@ -68,16 +68,24 @@ private:
/**
* Create a new CURL session.
*/
-const gc_ptr<http::CURLSession> newsession() {
- return new (gc_new<http::CURLSession>()) http::CURLSession("", "", "", "");
-}
+class newsession {
+public:
+ newsession(const lambda<value(const list<value>&)>& timeout) : timeout(timeout) {
+ }
+ const gc_ptr<http::CURLSession> operator()() const {
+ const int t = atoi(c_str((string)timeout(list<value>())));
+ return new (gc_new<http::CURLSession>()) http::CURLSession("", "", "", "", t);
+ }
+private:
+ const lambda<value(const list<value>&)> timeout;
+};
/**
* Start the component.
*/
const failable<value> start(const list<value>& params) {
// Create a CURL session
- const perthread_ptr<http::CURLSession> ch = perthread_ptr<http::CURLSession>(lambda<gc_ptr<http::CURLSession>()>(newsession));
+ const perthread_ptr<http::CURLSession> ch = perthread_ptr<http::CURLSession>(lambda<gc_ptr<http::CURLSession>()>(newsession(cadr(params))));
// Return the component implementation lambda function
return value(lambda<value(const list<value>&)>(applyhttp(car(params), ch)));