summaryrefslogtreecommitdiff
path: root/indra/llmessage/lliohttpserver.cpp
diff options
context:
space:
mode:
authorKyle Ambroff <ambroff@lindenlab.com>2008-06-21 07:39:52 +0000
committerKyle Ambroff <ambroff@lindenlab.com>2008-06-21 07:39:52 +0000
commitdc3f5ff87cfa085998bf69db6dedad45440419d3 (patch)
treee6c54376390a110e0e91ea0139ce6bb54925ffae /indra/llmessage/lliohttpserver.cpp
parentaf080d1c62f1a2cdc17c3870427f07ad0cf9534f (diff)
svn merge -r90150:90340 svn+ssh://svn.lindenlab.com/svn/linden/branches/qar-699_combo-merge --> release
QAR-699 - Combo merge for QAR-687, QAR-637, QAR-586 * QAR-687 - Test build with libs on S3 * QAR-637 Test dynamic sound throttle * QAR-586 Test new http features branch
Diffstat (limited to 'indra/llmessage/lliohttpserver.cpp')
-rw-r--r--indra/llmessage/lliohttpserver.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp
index ec5cb93d69..90f8ef7638 100644
--- a/indra/llmessage/lliohttpserver.cpp
+++ b/indra/llmessage/lliohttpserver.cpp
@@ -57,10 +57,13 @@
static const char HTTP_VERSION_STR[] = "HTTP/1.0";
static const std::string CONTEXT_REQUEST("request");
static const std::string CONTEXT_RESPONSE("response");
+static const std::string CONTEXT_VERB("verb");
+static const std::string CONTEXT_HEADERS("headers");
static const std::string HTTP_VERB_GET("GET");
static const std::string HTTP_VERB_PUT("PUT");
static const std::string HTTP_VERB_POST("POST");
static const std::string HTTP_VERB_DELETE("DELETE");
+static const std::string HTTP_VERB_OPTIONS("OPTIONS");
static LLIOHTTPServer::timing_callback_t sTimingCallback = NULL;
static void* sTimingCallbackData = NULL;
@@ -130,6 +133,7 @@ private:
LLSD mGoodResult;
S32 mStatusCode;
std::string mStatusMessage;
+ LLSD mHeaders;
};
LLIOPipe::EStatus LLHTTPPipe::process_impl(
@@ -164,7 +168,7 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl(
static LLTimer timer;
timer.reset();
- std::string verb = context[CONTEXT_REQUEST]["verb"];
+ std::string verb = context[CONTEXT_REQUEST][CONTEXT_VERB];
if(verb == HTTP_VERB_GET)
{
mNode.get(LLHTTPNode::ResponsePtr(mResponse), context);
@@ -185,6 +189,10 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl(
{
mNode.del(LLHTTPNode::ResponsePtr(mResponse), context);
}
+ else if(verb == HTTP_VERB_OPTIONS)
+ {
+ mNode.options(LLHTTPNode::ResponsePtr(mResponse), context);
+ }
else
{
mResponse->methodNotAllowed();
@@ -231,7 +239,9 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl(
case STATE_GOOD_RESULT:
{
- context[CONTEXT_RESPONSE]["contentType"] = "application/xml";
+ LLSD headers = mHeaders;
+ headers["Content-Type"] = "application/xml";
+ context[CONTEXT_RESPONSE][CONTEXT_HEADERS] = headers;
LLBufferStream ostr(channels, buffer.get());
LLSDSerialize::toXML(mGoodResult, ostr);
@@ -240,7 +250,9 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl(
case STATE_STATUS_RESULT:
{
- context[CONTEXT_RESPONSE]["contentType"] = "text/plain";
+ LLSD headers = mHeaders;
+ headers["Content-Type"] = "text/plain";
+ context[CONTEXT_RESPONSE][CONTEXT_HEADERS] = headers;
context[CONTEXT_RESPONSE]["statusCode"] = mStatusCode;
context[CONTEXT_RESPONSE]["statusMessage"] = mStatusMessage;
LLBufferStream ostr(channels, buffer.get());
@@ -287,6 +299,7 @@ void LLHTTPPipe::Response::result(const LLSD& r)
mPipe->mStatusMessage = "OK";
mPipe->mGoodResult = r;
mPipe->mState = STATE_GOOD_RESULT;
+ mPipe->mHeaders = mHeaders;
mPipe->unlockChain();
}
@@ -302,6 +315,7 @@ void LLHTTPPipe::Response::status(S32 code, const std::string& message)
mPipe->mStatusCode = code;
mPipe->mStatusMessage = message;
mPipe->mState = STATE_STATUS_RESULT;
+ mPipe->mHeaders = mHeaders;
mPipe->unlockChain();
}
@@ -389,17 +403,24 @@ LLIOPipe::EStatus LLHTTPResponseHeader::process_impl(
}
ostr << HTTP_VERSION_STR << " " << code << " " << message << "\r\n";
-
- std::string type = context[CONTEXT_RESPONSE]["contentType"].asString();
- if (!type.empty())
- {
- ostr << "Content-Type: " << type << "\r\n";
- }
S32 content_length = buffer->countAfter(channels.in(), NULL);
if(0 < content_length)
{
ostr << "Content-Length: " << content_length << "\r\n";
}
+ // *NOTE: This guard can go away once the LLSD static map
+ // iterator is available. Phoenix. 2008-05-09
+ LLSD headers = context[CONTEXT_RESPONSE][CONTEXT_HEADERS];
+ if(headers.isDefined())
+ {
+ LLSD::map_iterator iter = headers.beginMap();
+ LLSD::map_iterator end = headers.endMap();
+ for(; iter != end; ++iter)
+ {
+ ostr << (*iter).first << ": " << (*iter).second.asString()
+ << "\r\n";
+ }
+ }
ostr << "\r\n";
LLChangeChannel change(channels.in(), channels.out());
@@ -606,11 +627,12 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl(
read_next_line = true;
LLMemoryStream header((U8*)buf, len);
header >> mVerb;
-
+
if((HTTP_VERB_GET == mVerb)
|| (HTTP_VERB_POST == mVerb)
|| (HTTP_VERB_PUT == mVerb)
- || (HTTP_VERB_DELETE == mVerb))
+ || (HTTP_VERB_DELETE == mVerb)
+ || (HTTP_VERB_OPTIONS == mVerb))
{
header >> mAbsPathAndQuery;
header >> mVersion;
@@ -721,7 +743,7 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl(
{
// hey, hey, we should have everything now, so we pass it to
// a content handler.
- context[CONTEXT_REQUEST]["verb"] = mVerb;
+ context[CONTEXT_REQUEST][CONTEXT_VERB] = mVerb;
const LLHTTPNode* node = mRootNode.traverse(mPath, context);
if(node)
{
@@ -765,7 +787,7 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl(
= mBuildContext["remote-host"];
context[CONTEXT_REQUEST]["remote-port"]
= mBuildContext["remote-port"];
- context[CONTEXT_REQUEST]["headers"] = mHeaders;
+ context[CONTEXT_REQUEST][CONTEXT_HEADERS] = mHeaders;
const LLChainIOFactory* protocolHandler
= node->getProtocolHandler();