summaryrefslogtreecommitdiff
path: root/indra/llmessage/llhttpnode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/llhttpnode.cpp')
-rw-r--r--indra/llmessage/llhttpnode.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/indra/llmessage/llhttpnode.cpp b/indra/llmessage/llhttpnode.cpp
index 196aa5f8cf..91605b4008 100644
--- a/indra/llmessage/llhttpnode.cpp
+++ b/indra/llmessage/llhttpnode.cpp
@@ -174,6 +174,26 @@ LLSD LLHTTPNode::del(const LLSD&) const
throw NotImplemented();
}
+// virtual
+void LLHTTPNode::options(ResponsePtr response, const LLSD& context) const
+{
+ //llinfos << "options context: " << context << llendl;
+
+ // default implementation constructs an url to the documentation.
+ std::string host = context[CONTEXT_REQUEST]["headers"]["host"].asString();
+ if(host.empty())
+ {
+ response->status(400, "Bad Request -- need Host header");
+ return;
+ }
+ std::ostringstream ostr;
+ ostr << "http://" << host << "/web/server/api";
+ ostr << context[CONTEXT_REQUEST]["path"].asString();
+ static const std::string DOC_HEADER("X-Documentation-URL");
+ response->addHeader(DOC_HEADER, ostr.str());
+ response->status(200, "OK");
+}
+
// virtual
LLHTTPNode* LLHTTPNode::getChild(const std::string& name, LLSD& context) const
@@ -386,6 +406,13 @@ void LLHTTPNode::Response::methodNotAllowed()
status(405, "Method Not Allowed");
}
+void LLHTTPNode::Response::addHeader(
+ const std::string& name,
+ const std::string& value)
+{
+ mHeaders[name] = value;
+}
+
void LLHTTPNode::describe(Description& desc) const
{
desc.shortInfo("unknown service (missing describe() method)");