diff options
Diffstat (limited to 'indra/llmessage/llhttpnode.cpp')
-rwxr-xr-x | indra/llmessage/llhttpnode.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/indra/llmessage/llhttpnode.cpp b/indra/llmessage/llhttpnode.cpp index 5c2f73eccb..5058fdaf51 100755 --- a/indra/llmessage/llhttpnode.cpp +++ b/indra/llmessage/llhttpnode.cpp @@ -30,9 +30,15 @@ #include <boost/tokenizer.hpp> #include "llstl.h" -#include "lliohttpserver.h" // for string constants +#include "llhttpconstants.h" -static const std::string CONTEXT_WILDCARD("wildcard"); +const std::string CONTEXT_HEADERS("headers"); +const std::string CONTEXT_PATH("path"); +const std::string CONTEXT_QUERY_STRING("query-string"); +const std::string CONTEXT_REQUEST("request"); +const std::string CONTEXT_RESPONSE("response"); +const std::string CONTEXT_VERB("verb"); +const std::string CONTEXT_WILDCARD("wildcard"); /** * LLHTTPNode @@ -173,21 +179,23 @@ LLSD LLHTTPNode::simpleDel(const LLSD&) const void LLHTTPNode::options(ResponsePtr response, const LLSD& context) const { //llinfos << "options context: " << context << llendl; + LL_DEBUGS("LLHTTPNode") << "context: " << context << LL_ENDL; // default implementation constructs an url to the documentation. + // *TODO: Check for 'Host' header instead of 'host' header? std::string host( - context[CONTEXT_REQUEST][CONTEXT_HEADERS]["host"].asString()); + context[CONTEXT_REQUEST][CONTEXT_HEADERS][HTTP_IN_HEADER_HOST].asString()); if(host.empty()) { - response->status(400, "Bad Request -- need Host header"); + response->status(HTTP_BAD_REQUEST, "Bad Request -- need Host header"); return; } std::ostringstream ostr; ostr << "http://" << host << "/web/server/api"; - ostr << context[CONTEXT_REQUEST]["path"].asString(); + ostr << context[CONTEXT_REQUEST][CONTEXT_PATH].asString(); static const std::string DOC_HEADER("X-Documentation-URL"); response->addHeader(DOC_HEADER, ostr.str()); - response->status(200, "OK"); + response->status(HTTP_OK, "OK"); } @@ -389,17 +397,17 @@ void LLHTTPNode::Response::statusUnknownError(S32 code) void LLHTTPNode::Response::notFound(const std::string& message) { - status(404, message); + status(HTTP_NOT_FOUND, message); } void LLHTTPNode::Response::notFound() { - status(404, "Not Found"); + status(HTTP_NOT_FOUND, "Not Found"); } void LLHTTPNode::Response::methodNotAllowed() { - status(405, "Method Not Allowed"); + status(HTTP_METHOD_NOT_ALLOWED, "Method Not Allowed"); } void LLHTTPNode::Response::addHeader( @@ -467,7 +475,7 @@ LLSimpleResponse::~LLSimpleResponse() void LLSimpleResponse::result(const LLSD& result) { - status(200, "OK"); + status(HTTP_OK, "OK"); } void LLSimpleResponse::extendedResult(S32 code, const std::string& body, const LLSD& headers) @@ -475,6 +483,11 @@ void LLSimpleResponse::extendedResult(S32 code, const std::string& body, const L status(code,body); } +void LLSimpleResponse::extendedResult(S32 code, const LLSD& r, const LLSD& headers) +{ + status(code,"(LLSD)"); +} + void LLSimpleResponse::status(S32 code, const std::string& message) { mCode = code; |