From 419f903ff44a22debba43976baae1e86c1e5d871 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 16 Jul 2012 06:47:59 +0000 Subject: Add a timeout property to the CURL HTTP clients. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1361916 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/server/client-test.hpp | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'sca-cpp/trunk/modules/server/client-test.hpp') diff --git a/sca-cpp/trunk/modules/server/client-test.hpp b/sca-cpp/trunk/modules/server/client-test.hpp index 2207127e67..1c7b26da39 100644 --- a/sca-cpp/trunk/modules/server/client-test.hpp +++ b/sca-cpp/trunk/modules/server/client-test.hpp @@ -46,7 +46,7 @@ ostream* curlWriter(const string& s, ostream* os) { const bool testGet() { gc_scoped_pool pool; - http::CURLSession ch("", "", "", ""); + http::CURLSession ch("", "", "", "", 0); { ostringstream os; const failable > r = http::get(curlWriter, &os, "http://localhost:8090/index.html", ch); @@ -63,7 +63,7 @@ const bool testGet() { } struct getLoop { - http::CURLSession ch; + http::CURLSession& ch; getLoop(http::CURLSession& ch) : ch(ch) { } const bool operator()() const { @@ -76,7 +76,7 @@ struct getLoop { const bool testGetPerf() { gc_scoped_pool pool; - http::CURLSession ch("", "", "", ""); + http::CURLSession ch("", "", "", "", 0); const lambda gl = getLoop(ch); cout << "Static GET test " << time(gl, 5, 200) << " ms" << endl; return true; @@ -84,7 +84,7 @@ const bool testGetPerf() { const bool testEval() { gc_scoped_pool pool; - http::CURLSession ch("", "", "", ""); + http::CURLSession ch("", "", "", "", 0); const failable r = http::evalExpr(mklist(string("echo"), string("Hello")), testURI, ch); assert(hasContent(r)); assert(content(r) == string("Hello")); @@ -93,7 +93,7 @@ const bool testEval() { struct evalLoop { const string uri; - http::CURLSession ch; + http::CURLSession& ch; evalLoop(const string& uri, http::CURLSession& ch) : uri(uri), ch(ch) { } const bool operator()() const { @@ -109,7 +109,7 @@ const list blobs = mklist(blob, blob); struct blobEvalLoop { const string uri; - http::CURLSession ch; + http::CURLSession& ch; blobEvalLoop(const string& uri, http::CURLSession& ch) : uri(uri), ch(ch) { } const bool operator()() const { @@ -122,7 +122,7 @@ struct blobEvalLoop { const bool testEvalPerf() { gc_scoped_pool pool; - http::CURLSession ch("", "", "", ""); + http::CURLSession ch("", "", "", "", 0); const lambda el = evalLoop(testURI, ch); cout << "JSON-RPC eval echo test " << time(el, 5, 200) << " ms" << endl; @@ -142,7 +142,7 @@ bool testPost() { + (list() + "title" + string("item")) + (list() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")) + i); - http::CURLSession ch("", "", "", ""); + http::CURLSession ch("", "", "", "", 0); const failable id = http::post(a, testURI, ch); assert(hasContent(id)); return true; @@ -151,7 +151,7 @@ bool testPost() { struct postLoop { const string uri; const value val; - http::CURLSession ch; + http::CURLSession& ch; postLoop(const string& uri, const value& val, http::CURLSession& ch) : uri(uri), val(val), ch(ch) { } const bool operator()() const { @@ -164,7 +164,7 @@ struct postLoop { struct postBlobLoop { const string uri; const value val; - http::CURLSession ch; + http::CURLSession& ch; postBlobLoop(const string& uri, const value& val, http::CURLSession& ch) : uri(uri), val(val), ch(ch) { } const bool operator()() const { @@ -177,7 +177,7 @@ struct postBlobLoop { const bool testPostPerf() { gc_scoped_pool pool; - http::CURLSession ch("", "", "", ""); + http::CURLSession ch("", "", "", "", 0); { const list i = list() + "content" + (list() + "item" + (list() + "name" + string("Apple")) @@ -209,7 +209,7 @@ const bool testPostPerf() { const bool postThread(const string& uri, const int count, const value& val) { gc_scoped_pool pool; - http::CURLSession ch("", "", "", ""); + http::CURLSession ch("", "", "", "", 0); const lambda pl = postLoop(uri, val, ch); time(pl, 0, count); return true; @@ -267,7 +267,7 @@ const bool testPostThreadPerf() { const bool postProc(const string& uri, const int count, const value& val) { gc_scoped_pool pool; - http::CURLSession ch("", "", "", ""); + http::CURLSession ch("", "", "", "", 0); const lambda pl = postLoop(uri, val, ch); time(pl, 0, count); return true; @@ -337,7 +337,7 @@ const bool testPut() { + (list() + "title" + string("item")) + (list() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")) + i); - http::CURLSession ch("", "", "", ""); + http::CURLSession ch("", "", "", "", 0); value rc = content(http::put(a, testURI + "/111", ch)); assert(rc == value(true)); return true; @@ -345,7 +345,7 @@ const bool testPut() { const bool testDel() { gc_scoped_pool pool; - http::CURLSession ch("", "", "", ""); + http::CURLSession ch("", "", "", "", 0); value rc = content(http::del(testURI + "/111", ch)); assert(rc == value(true)); return true; -- cgit v1.2.3