summaryrefslogtreecommitdiff
path: root/indra/test/mock_http_client.cpp
diff options
context:
space:
mode:
authorDave Hiller <daveh@lindenlab.com>2008-07-31 12:15:15 +0000
committerDave Hiller <daveh@lindenlab.com>2008-07-31 12:15:15 +0000
commit9a7d68cfce5f71cf9d89536431d72941dc369749 (patch)
treef7e0ce093abef0fcc7737cac63bc2a8dbf11b729 /indra/test/mock_http_client.cpp
parentf0f2a416911ba8de9ac1e08cd90720c0d789bb2e (diff)
svn merge -r93014:93396 svn+ssh://svn.lindenlab.com/svn/linden/branches/mono-r93014-qar633 dataserver-is-deprecated
Diffstat (limited to 'indra/test/mock_http_client.cpp')
-rw-r--r--indra/test/mock_http_client.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/indra/test/mock_http_client.cpp b/indra/test/mock_http_client.cpp
new file mode 100644
index 0000000000..6b273ee7b5
--- /dev/null
+++ b/indra/test/mock_http_client.cpp
@@ -0,0 +1,66 @@
+/**
+ * @file mock_http_client.cpp
+ * @brief Framework for testing HTTP requests
+ * Copyright (c) 2007, Linden Research, Inc.
+ *
+ * $LicenseInfo:firstyear=2007&license=viewergpl$
+ * $/LicenseInfo$
+ */
+
+#include "linden_common.h"
+#include "llsdhttpserver.h"
+#include "lliohttpserver.h"
+
+namespace tut
+{
+ class SuccessNode : public LLHTTPNode
+ {
+ public:
+ void get(ResponsePtr r, const LLSD& context) const
+ {
+ LLSD result;
+ result["state"] = "complete";
+ result["test"] = "test";
+ r->result(result);
+ }
+ void post(ResponsePtr r, const LLSD& context, const LLSD& input) const
+ {
+ LLSD result;
+ result["state"] = "complete";
+ result["test"] = "test";
+ r->result(result);
+ }
+ };
+
+ class ErrorNode : public LLHTTPNode
+ {
+ public:
+ void get(ResponsePtr r, const LLSD& context) const
+ { r->status(599, "Intentional error"); }
+ void post(ResponsePtr r, const LLSD& context, const LLSD& input) const
+ { r->status(input["status"], input["reason"]); }
+ };
+
+ class TimeOutNode : public LLHTTPNode
+ {
+ public:
+ void get(ResponsePtr r, const LLSD& context) const
+ {
+ /* do nothing, the request will eventually time out */
+ }
+ };
+
+ LLSD storage;
+
+ class LLSDStorageNode : public LLHTTPNode
+ {
+ public:
+ LLSD get() const{ return storage; }
+ LLSD put(const LLSD& value) const{ storage = value; return LLSD(); }
+ };
+
+ LLHTTPRegistration<LLSDStorageNode> gStorageNode("/test/storage");
+ LLHTTPRegistration<SuccessNode> gSuccessNode("/test/success");
+ LLHTTPRegistration<ErrorNode> gErrorNode("/test/error");
+ LLHTTPRegistration<TimeOutNode> gTimeOutNode("/test/timeout");
+}