summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/components/http
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/components/http')
-rw-r--r--sca-cpp/trunk/components/http/client-test.cpp14
-rw-r--r--sca-cpp/trunk/components/http/http.composite5
-rw-r--r--sca-cpp/trunk/components/http/httpdelete.componentType1
-rw-r--r--sca-cpp/trunk/components/http/httpdelete.cpp20
-rw-r--r--sca-cpp/trunk/components/http/httpget.componentType1
-rw-r--r--sca-cpp/trunk/components/http/httpget.cpp20
-rw-r--r--sca-cpp/trunk/components/http/httppatch.componentType1
-rw-r--r--sca-cpp/trunk/components/http/httppatch.cpp20
-rw-r--r--sca-cpp/trunk/components/http/httppost.componentType1
-rw-r--r--sca-cpp/trunk/components/http/httppost.cpp20
-rw-r--r--sca-cpp/trunk/components/http/httpput.componentType1
-rw-r--r--sca-cpp/trunk/components/http/httpput.cpp20
12 files changed, 87 insertions, 37 deletions
diff --git a/sca-cpp/trunk/components/http/client-test.cpp b/sca-cpp/trunk/components/http/client-test.cpp
index c040ed39df..bb1918f1f8 100644
--- a/sca-cpp/trunk/components/http/client-test.cpp
+++ b/sca-cpp/trunk/components/http/client-test.cpp
@@ -42,7 +42,7 @@ const string putURI("http://localhost:8090/httpput");
const string deleteURI("http://localhost:8090/httpdelete");
bool testGet() {
- http::CURLSession cs("", "", "", "");
+ http::CURLSession cs("", "", "", "", 0);
const failable<value> val = http::get(getURI, cs);
assert(hasContent(val));
@@ -50,8 +50,8 @@ bool testGet() {
}
struct getLoop {
- http::CURLSession cs;
- getLoop(http::CURLSession cs) : cs(cs) {
+ http::CURLSession& cs;
+ getLoop(http::CURLSession& cs) : cs(cs) {
}
const bool operator()() const {
const failable<value> val = http::get(getURI, cs);
@@ -61,7 +61,7 @@ struct getLoop {
};
bool testGetPerf() {
- http::CURLSession cs("", "", "", "");
+ http::CURLSession cs("", "", "", "", 0);
const lambda<bool()> gl = getLoop(cs);
cout << "HTTP get test " << time(gl, 5, 200) << " ms" << endl;
@@ -70,7 +70,7 @@ bool testGetPerf() {
}
bool testPost() {
- http::CURLSession cs("", "", "", "");
+ http::CURLSession cs("", "", "", "", 0);
const failable<value> val = http::get(postURI, cs);
assert(hasContent(val));
@@ -78,7 +78,7 @@ bool testPost() {
}
bool testPut() {
- http::CURLSession cs("", "", "", "");
+ http::CURLSession cs("", "", "", "", 0);
const failable<value> val = http::get(putURI, cs);
assert(hasContent(val));
@@ -86,7 +86,7 @@ bool testPut() {
}
bool testDelete() {
- http::CURLSession cs("", "", "", "");
+ http::CURLSession cs("", "", "", "", 0);
const failable<value> val = http::get(deleteURI, cs);
assert(hasContent(val));
diff --git a/sca-cpp/trunk/components/http/http.composite b/sca-cpp/trunk/components/http/http.composite
index ea0adedf51..32c0da62c0 100644
--- a/sca-cpp/trunk/components/http/http.composite
+++ b/sca-cpp/trunk/components/http/http.composite
@@ -23,6 +23,7 @@
<component name="httpget">
<implementation.cpp path="." library="libhttpget"/>
+ <property name="timeout">0</property>
<service name="httpget">
<binding.http uri="httpget"/>
</service>
@@ -31,6 +32,7 @@
<component name="httppost">
<implementation.cpp path="." library="libhttppost"/>
+ <property name="timeout">0</property>
<service name="httppost">
<binding.http uri="httppost"/>
</service>
@@ -40,6 +42,7 @@
<component name="httpput">
<implementation.cpp path="." library="libhttpput"/>
+ <property name="timeout">0</property>
<service name="httpput">
<binding.http uri="httpput"/>
</service>
@@ -49,6 +52,7 @@
<component name="httppatch">
<implementation.cpp path="." library="libhttppatch"/>
+ <property name="timeout">0</property>
<service name="httppatch">
<binding.http uri="httppatch"/>
</service>
@@ -58,6 +62,7 @@
<component name="httpdelete">
<implementation.cpp path="." library="libhttpdelete"/>
+ <property name="timeout">0</property>
<service name="httpdelete">
<binding.http uri="httpdelete"/>
</service>
diff --git a/sca-cpp/trunk/components/http/httpdelete.componentType b/sca-cpp/trunk/components/http/httpdelete.componentType
index 34e2a60632..c2d728a538 100644
--- a/sca-cpp/trunk/components/http/httpdelete.componentType
+++ b/sca-cpp/trunk/components/http/httpdelete.componentType
@@ -22,6 +22,7 @@
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
targetNamespace="http://tuscany.apache.org/xmlns/sca/components">
+ <property name="timeout"/>
<service name="httpdelete"/>
<reference name="url"/>
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)));
diff --git a/sca-cpp/trunk/components/http/httpget.componentType b/sca-cpp/trunk/components/http/httpget.componentType
index a45474b88d..c6c24fbed8 100644
--- a/sca-cpp/trunk/components/http/httpget.componentType
+++ b/sca-cpp/trunk/components/http/httpget.componentType
@@ -22,6 +22,7 @@
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
targetNamespace="http://tuscany.apache.org/xmlns/sca/components">
+ <property name="timeout"/>
<service name="httpget"/>
<reference name="url"/>
diff --git a/sca-cpp/trunk/components/http/httpget.cpp b/sca-cpp/trunk/components/http/httpget.cpp
index 8515d6f41e..884dc1a6ff 100644
--- a/sca-cpp/trunk/components/http/httpget.cpp
+++ b/sca-cpp/trunk/components/http/httpget.cpp
@@ -38,7 +38,7 @@ namespace httpget {
/**
* Evaluate an HTTP get.
*/
-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("httpget::get");
const value u = url(mklist<value>("get", list<value>()));
debug(u, "httpget::get::url");
@@ -50,7 +50,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 {
@@ -70,16 +70,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)));
diff --git a/sca-cpp/trunk/components/http/httppatch.componentType b/sca-cpp/trunk/components/http/httppatch.componentType
index 0ab5ecf45b..eb3a96078b 100644
--- a/sca-cpp/trunk/components/http/httppatch.componentType
+++ b/sca-cpp/trunk/components/http/httppatch.componentType
@@ -22,6 +22,7 @@
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
targetNamespace="http://tuscany.apache.org/xmlns/sca/components">
+ <property name="timeout"/>
<service name="httppatch"/>
<reference name="url"/>
<reference name="content"/>
diff --git a/sca-cpp/trunk/components/http/httppatch.cpp b/sca-cpp/trunk/components/http/httppatch.cpp
index 3e6f7af2c0..051b1e09ac 100644
--- a/sca-cpp/trunk/components/http/httppatch.cpp
+++ b/sca-cpp/trunk/components/http/httppatch.cpp
@@ -38,7 +38,7 @@ namespace httppatch {
/**
* Evaluate an HTTP patch.
*/
-const failable<value> get(const lambda<value(const list<value>&)> url, const lambda<value(const list<value>&)> val, http::CURLSession& ch) {
+const failable<value> get(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, http::CURLSession& ch) {
debug("httppatch::get");
const value u = url(mklist<value>("get", list<value>()));
const value v = val(mklist<value>("get", list<value>()));
@@ -52,7 +52,7 @@ const failable<value> get(const lambda<value(const list<value>&)> url, const lam
*/
class applyhttp {
public:
- applyhttp(const lambda<value(const list<value>&)> url, const lambda<value(const list<value>&)> val, const perthread_ptr<http::CURLSession>& ch) : url(url), val(val), ch(ch) {
+ applyhttp(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, const perthread_ptr<http::CURLSession>& ch) : url(url), val(val), ch(ch) {
}
const value operator()(const list<value>& params) const {
@@ -72,16 +72,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(caddr(params))));
// Return the component implementation lambda function
return value(lambda<value(const list<value>&)>(applyhttp(car(params), cadr(params), ch)));
diff --git a/sca-cpp/trunk/components/http/httppost.componentType b/sca-cpp/trunk/components/http/httppost.componentType
index 2cb7310332..42b0096446 100644
--- a/sca-cpp/trunk/components/http/httppost.componentType
+++ b/sca-cpp/trunk/components/http/httppost.componentType
@@ -22,6 +22,7 @@
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
targetNamespace="http://tuscany.apache.org/xmlns/sca/components">
+ <property name="timeout"/>
<service name="httppost"/>
<reference name="url"/>
<reference name="content"/>
diff --git a/sca-cpp/trunk/components/http/httppost.cpp b/sca-cpp/trunk/components/http/httppost.cpp
index 8d0f526bdc..84fd984e19 100644
--- a/sca-cpp/trunk/components/http/httppost.cpp
+++ b/sca-cpp/trunk/components/http/httppost.cpp
@@ -38,7 +38,7 @@ namespace httppost {
/**
* Evaluate an HTTP post.
*/
-const failable<value> get(const lambda<value(const list<value>&)> url, const lambda<value(const list<value>&)> val, http::CURLSession& ch) {
+const failable<value> get(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, http::CURLSession& ch) {
debug("httppost::get");
const value u = url(mklist<value>("get", list<value>()));
const value v = val(mklist<value>("get", list<value>()));
@@ -52,7 +52,7 @@ const failable<value> get(const lambda<value(const list<value>&)> url, const lam
*/
class applyhttp {
public:
- applyhttp(const lambda<value(const list<value>&)> url, const lambda<value(const list<value>&)> val, const perthread_ptr<http::CURLSession>& ch) : url(url), val(val), ch(ch) {
+ applyhttp(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, const perthread_ptr<http::CURLSession>& ch) : url(url), val(val), ch(ch) {
}
const value operator()(const list<value>& params) const {
@@ -72,16 +72,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<const 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(caddr(params))));
// Return the component implementation lambda function
return value(lambda<value(const list<value>&)>(applyhttp(car(params), cadr(params), ch)));
diff --git a/sca-cpp/trunk/components/http/httpput.componentType b/sca-cpp/trunk/components/http/httpput.componentType
index 654bb5e82f..791a7faa8a 100644
--- a/sca-cpp/trunk/components/http/httpput.componentType
+++ b/sca-cpp/trunk/components/http/httpput.componentType
@@ -22,6 +22,7 @@
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
targetNamespace="http://tuscany.apache.org/xmlns/sca/components">
+ <property name="timeout"/>
<service name="httpput"/>
<reference name="url"/>
<reference name="content"/>
diff --git a/sca-cpp/trunk/components/http/httpput.cpp b/sca-cpp/trunk/components/http/httpput.cpp
index c157ee32cc..2ae5da396e 100644
--- a/sca-cpp/trunk/components/http/httpput.cpp
+++ b/sca-cpp/trunk/components/http/httpput.cpp
@@ -38,7 +38,7 @@ namespace httpput {
/**
* Evaluate an HTTP put.
*/
-const failable<value> get(const lambda<value(const list<value>&)> url, const lambda<value(const list<value>&)> val, http::CURLSession& ch) {
+const failable<value> get(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, http::CURLSession& ch) {
debug("httpput::get");
const value u = url(mklist<value>("get", list<value>()));
const value v = val(mklist<value>("get", list<value>()));
@@ -52,7 +52,7 @@ const failable<value> get(const lambda<value(const list<value>&)> url, const lam
*/
class applyhttp {
public:
- applyhttp(const lambda<value(const list<value>&)> url, const lambda<value(const list<value>&)> val, const perthread_ptr<http::CURLSession>& ch) : url(url), val(val), ch(ch) {
+ applyhttp(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, const perthread_ptr<http::CURLSession>& ch) : url(url), val(val), ch(ch) {
}
const value operator()(const list<value>& params) const {
@@ -72,16 +72,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(caddr(params))));
// Return the component implementation lambda function
return value(lambda<value(const list<value>&)>(applyhttp(car(params), cadr(params), ch)));