aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/lliohttpserver.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmessage/lliohttpserver.h')
-rw-r--r--linden/indra/llmessage/lliohttpserver.h114
1 files changed, 114 insertions, 0 deletions
diff --git a/linden/indra/llmessage/lliohttpserver.h b/linden/indra/llmessage/lliohttpserver.h
new file mode 100644
index 0000000..efbd7db
--- /dev/null
+++ b/linden/indra/llmessage/lliohttpserver.h
@@ -0,0 +1,114 @@
1/**
2 * @file lliohttpserver.h
3 * @brief Declaration of function for creating an HTTP wire server
4 * @see LLIOServerSocket, LLPumpIO
5 *
6 * Copyright (c) 2005-2007, Linden Research, Inc.
7 *
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#ifndef LL_LLIOHTTPSERVER_H
30#define LL_LLIOHTTPSERVER_H
31
32#include "llapr.h"
33#include "llchainio.h"
34#include "llhttpnode.h"
35
36class LLPumpIO;
37
38LLHTTPNode& LLCreateHTTPServer(apr_pool_t* pool, LLPumpIO& pump, U16 port);
39 /**< Creates an HTTP wire server on the pump for the given TCP port.
40 *
41 * Returns the root node of the new server. Add LLHTTPNode instances
42 * to this root.
43 *
44 * Nodes that return NULL for getProtocolHandler(), will use the
45 * default handler that interprets HTTP on the wire and converts
46 * it into calls to get(), put(), post(), del() with appropriate
47 * LLSD arguments and results.
48 *
49 * To have nodes that implement some other wire protocol (XML-RPC
50 * for example), use the helper templates below.
51 */
52
53void LLCreateHTTPPipe(LLPumpIO::chain_t& chain, const LLHTTPNode& root);
54 /**< Create a pipe on the chain that handles HTTP requests.
55 * The requests are served by the node tree given at root.
56 *
57 * This is primarily useful for unit testing.
58 */
59
60/* @name Helper Templates
61 *
62 * These templates make it easy to create nodes that use thier own protocol
63 * handlers rather than the default. Typically, you subclass LLIOPipe to
64 * implement the protocol, and then add a node using the templates:
65 *
66 * rootNode->addNode("thing", new LLHTTPNodeForPipe<LLThingPipe>);
67 *
68 * The templates are:
69 *
70 * LLChainIOFactoryForPipe
71 * - a simple factory that builds instances of a pipe
72 *
73 * LLHTTPNodeForFacotry
74 * - a HTTP node that uses a factory as the protocol handler
75 *
76 * LLHTTPNodeForPipe
77 * - a HTTP node that uses a simple factory based on a pipe
78 */
79//@{
80
81template<class Pipe>
82class LLChainIOFactoryForPipe : public LLChainIOFactory
83{
84public:
85 virtual bool build(LLPumpIO::chain_t& chain, LLSD context) const
86 {
87 chain.push_back(LLIOPipe::ptr_t(new Pipe));
88 return true;
89 }
90};
91
92template<class Factory>
93class LLHTTPNodeForFactory : public LLHTTPNode
94{
95public:
96 const LLChainIOFactory* getProtocolHandler() const
97 { return &mProtocolHandler; }
98
99private:
100 Factory mProtocolHandler;
101};
102
103//@}
104
105
106template<class Pipe>
107class LLHTTPNodeForPipe : public LLHTTPNodeForFactory<
108 LLChainIOFactoryForPipe<Pipe> >
109{
110};
111
112
113#endif // LL_LLIOHTTPSERVER_H
114