summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-02-28 11:14:54 +0000
committerrandomdan <randomdan@localhost>2011-02-28 11:14:54 +0000
commit430ddb6b59ed9375bcb08aadd6385489c413dabc (patch)
treec630d95ca43dc823f8fbe770f79c927172b47b18
parentOnly initialise program_options once (only really affects p2fcgi) (diff)
downloadproject2-430ddb6b59ed9375bcb08aadd6385489c413dabc.tar.bz2
project2-430ddb6b59ed9375bcb08aadd6385489c413dabc.tar.xz
project2-430ddb6b59ed9375bcb08aadd6385489c413dabc.zip
Add support for a timeout, settable in ms, defaulting to 6000, for xslRows
-rw-r--r--project2/curlHelper.cpp22
-rw-r--r--project2/curlHelper.h4
2 files changed, 18 insertions, 8 deletions
diff --git a/project2/curlHelper.cpp b/project2/curlHelper.cpp
index eb6bf74..742e4de 100644
--- a/project2/curlHelper.cpp
+++ b/project2/curlHelper.cpp
@@ -7,7 +7,8 @@ CurlHelper::CurlHelper(const xmlpp::Element * p) :
proxy(p, "proxy", false),
method(p, "username", false),
userName(p, "username", false),
- password(p, "password", false)
+ password(p, "password", false),
+ timeout(p, "timeout", false, Variable(6000))
{
}
@@ -21,17 +22,24 @@ CurlHelper::newCurl() const
CurlHandle::Ptr c = new CurlHandle();
c->setopt(CURLOPT_FOLLOWLOCATION, 1);
c->setopt(CURLOPT_ENCODING, "deflate, gzip");
- setopt(c, CURLOPT_URL, url());
- setopt(c, CURLOPT_USERAGENT, userAgent());
- setopt(c, CURLOPT_PROXY, proxy());
- setopt(c, CURLOPT_COOKIEFILE, cookieJar());
- setopt(c, CURLOPT_COOKIEJAR, cookieJar());
+ setopt_s(c, CURLOPT_URL, url());
+ setopt_s(c, CURLOPT_USERAGENT, userAgent());
+ setopt_s(c, CURLOPT_PROXY, proxy());
+ setopt_s(c, CURLOPT_COOKIEFILE, cookieJar());
+ setopt_s(c, CURLOPT_COOKIEJAR, cookieJar());
+ setopt_l(c, CURLOPT_TIMEOUT_MS, timeout());
return c;
}
void
-CurlHelper::setopt(CurlHandle::Ptr c, CURLoption o, const char * v)
+CurlHelper::setopt_s(CurlHandle::Ptr c, CURLoption o, const char * v)
{
c->setopt(o, v);
}
+void
+CurlHelper::setopt_l(CurlHandle::Ptr c, CURLoption o, int64_t v)
+{
+ c->setopt(o, (long)v);
+}
+
diff --git a/project2/curlHelper.h b/project2/curlHelper.h
index fd4d265..af26a50 100644
--- a/project2/curlHelper.h
+++ b/project2/curlHelper.h
@@ -16,7 +16,8 @@ class CurlHelper {
CurlHandle::Ptr newCurl() const;
private:
- static void setopt(CurlHandle::Ptr, CURLoption, const char *);
+ static void setopt_s(CurlHandle::Ptr, CURLoption, const char *);
+ static void setopt_l(CurlHandle::Ptr, CURLoption, int64_t);
const Variable userAgent;
const Variable cookieJar;
@@ -24,6 +25,7 @@ class CurlHelper {
const Variable method;
const Variable userName;
const Variable password;
+ const Variable timeout;
};
#endif