aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/lliohttpserver.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:56 -0500
committerJacek Antonelli2008-08-15 23:44:56 -0500
commitc07901e29ed545bbb02e3bddf148fe1104b94e9f (patch)
treef1ada64ce834acd7d92a425efb96c4b86bcf16b1 /linden/indra/llmessage/lliohttpserver.cpp
parentSecond Life viewer sources 1.15.0.2 (diff)
downloadmeta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.zip
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.gz
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.bz2
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.xz
Second Life viewer sources 1.15.1.3
Diffstat (limited to '')
-rw-r--r--linden/indra/llmessage/lliohttpserver.cpp44
1 files changed, 37 insertions, 7 deletions
diff --git a/linden/indra/llmessage/lliohttpserver.cpp b/linden/indra/llmessage/lliohttpserver.cpp
index 9ea7272..d7fc54e 100644
--- a/linden/indra/llmessage/lliohttpserver.cpp
+++ b/linden/indra/llmessage/lliohttpserver.cpp
@@ -29,9 +29,8 @@
29 */ 29 */
30 30
31#include "linden_common.h" 31#include "linden_common.h"
32#include "lliohttpserver.h"
33 32
34#include "boost/tokenizer.hpp" 33#include "lliohttpserver.h"
35 34
36#include "llapr.h" 35#include "llapr.h"
37#include "llbuffer.h" 36#include "llbuffer.h"
@@ -46,9 +45,12 @@
46#include "llsd.h" 45#include "llsd.h"
47#include "llsdserialize_xml.h" 46#include "llsdserialize_xml.h"
48#include "llstl.h" 47#include "llstl.h"
48#include "lltimer.h"
49 49
50#include <sstream> 50#include <sstream>
51 51
52#include "boost/tokenizer.hpp"
53
52static const char HTTP_VERSION_STR[] = "HTTP/1.0"; 54static const char HTTP_VERSION_STR[] = "HTTP/1.0";
53static const std::string CONTEXT_REQUEST("request"); 55static const std::string CONTEXT_REQUEST("request");
54static const std::string HTTP_VERB_GET("GET"); 56static const std::string HTTP_VERB_GET("GET");
@@ -56,6 +58,8 @@ static const std::string HTTP_VERB_PUT("PUT");
56static const std::string HTTP_VERB_POST("POST"); 58static const std::string HTTP_VERB_POST("POST");
57static const std::string HTTP_VERB_DELETE("DELETE"); 59static const std::string HTTP_VERB_DELETE("DELETE");
58 60
61static LLIOHTTPServer::timing_callback_t sTimingCallback = NULL;
62static void* sTimingCallbackData = NULL;
59 63
60class LLHTTPPipe : public LLIOPipe 64class LLHTTPPipe : public LLIOPipe
61{ 65{
@@ -151,6 +155,12 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl(
151 // TODO: Babbage: Parameterize parser? 155 // TODO: Babbage: Parameterize parser?
152 LLBufferStream istr(channels, buffer.get()); 156 LLBufferStream istr(channels, buffer.get());
153 157
158 static LLTimer timer;
159 if (sTimingCallback)
160 {
161 timer.reset();
162 }
163
154 std::string verb = context[CONTEXT_REQUEST]["verb"]; 164 std::string verb = context[CONTEXT_REQUEST]["verb"];
155 if(verb == HTTP_VERB_GET) 165 if(verb == HTTP_VERB_GET)
156 { 166 {
@@ -179,6 +189,18 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl(
179 mResponse->methodNotAllowed(); 189 mResponse->methodNotAllowed();
180 } 190 }
181 191
192 if (sTimingCallback)
193 {
194 LLHTTPNode::Description desc;
195 mNode.describe(desc);
196 LLSD info = desc.getInfo();
197 std::string timing_name = info["description"];
198 timing_name += " ";
199 timing_name += verb;
200 F32 delta = timer.getElapsedTimeF32();
201 sTimingCallback(timing_name.c_str(), delta, sTimingCallbackData);
202 }
203
182 // Log Internal Server Errors 204 // Log Internal Server Errors
183 if(mStatusCode == 500) 205 if(mStatusCode == 500)
184 { 206 {
@@ -819,9 +841,9 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl(
819} 841}
820 842
821 843
822 844// static
823void LLCreateHTTPPipe(LLPumpIO::chain_t& chain, 845void LLIOHTTPServer::createPipe(LLPumpIO::chain_t& chain,
824 const LLHTTPNode& root, const LLSD& ctx) 846 const LLHTTPNode& root, const LLSD& ctx)
825{ 847{
826 chain.push_back(LLIOPipe::ptr_t(new LLHTTPResponder(root, ctx))); 848 chain.push_back(LLIOPipe::ptr_t(new LLHTTPResponder(root, ctx)));
827} 849}
@@ -832,7 +854,7 @@ class LLHTTPResponseFactory : public LLChainIOFactory
832public: 854public:
833 bool build(LLPumpIO::chain_t& chain, LLSD ctx) const 855 bool build(LLPumpIO::chain_t& chain, LLSD ctx) const
834 { 856 {
835 LLCreateHTTPPipe(chain, mTree, ctx); 857 LLIOHTTPServer::createPipe(chain, mTree, ctx);
836 return true; 858 return true;
837 } 859 }
838 860
@@ -843,7 +865,8 @@ private:
843}; 865};
844 866
845 867
846LLHTTPNode& LLCreateHTTPServer( 868// static
869LLHTTPNode& LLIOHTTPServer::create(
847 apr_pool_t* pool, LLPumpIO& pump, U16 port) 870 apr_pool_t* pool, LLPumpIO& pump, U16 port)
848{ 871{
849 LLSocket::ptr_t socket = LLSocket::create( 872 LLSocket::ptr_t socket = LLSocket::create(
@@ -867,3 +890,10 @@ LLHTTPNode& LLCreateHTTPServer(
867 return factory->getRootNode(); 890 return factory->getRootNode();
868} 891}
869 892
893// static
894void LLIOHTTPServer::setTimingCallback(timing_callback_t callback,
895 void* data)
896{
897 sTimingCallback = callback;
898 sTimingCallbackData = data;
899}