aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llhttpnode.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmessage/llhttpnode.h')
-rw-r--r--linden/indra/llmessage/llhttpnode.h78
1 files changed, 47 insertions, 31 deletions
diff --git a/linden/indra/llmessage/llhttpnode.h b/linden/indra/llmessage/llhttpnode.h
index ea89ee2..17ffd66 100644
--- a/linden/indra/llmessage/llhttpnode.h
+++ b/linden/indra/llmessage/llhttpnode.h
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -37,7 +38,6 @@
37 38
38class LLChainIOFactory; 39class LLChainIOFactory;
39 40
40
41/** 41/**
42 * These classes represent the HTTP framework: The URL tree, and the LLSD 42 * These classes represent the HTTP framework: The URL tree, and the LLSD
43 * REST interface that such nodes implement. 43 * REST interface that such nodes implement.
@@ -88,6 +88,9 @@ public:
88 virtual LLSD post(const LLSD& input) const; 88 virtual LLSD post(const LLSD& input) const;
89 virtual LLSD del(const LLSD& context) const; 89 virtual LLSD del(const LLSD& context) const;
90 90
91 /**
92 * @brief Abstract Base Class declaring Response interface.
93 */
91 class Response : public LLRefCount 94 class Response : public LLRefCount
92 { 95 {
93 protected: 96 protected:
@@ -95,53 +98,57 @@ public:
95 98
96 public: 99 public:
97 /** 100 /**
98 * @brief Return the LLSD content and a 200 OK. 101 * @brief Return the LLSD content and a 200 OK.
99 */ 102 */
100 virtual void result(const LLSD&) = 0; 103 virtual void result(const LLSD&) = 0;
101 104
102 /** 105 /**
106 * @brief return status code and message with headers.
107 */
108 virtual void extendedResult(S32 code, const std::string& message, const LLSD& headers) = 0;
109
110 /**
103 * @brief return status code and reason string on http header, 111 * @brief return status code and reason string on http header,
104 * but do not return a payload. 112 * but do not return a payload.
105 */ 113 */
106 virtual void status(S32 code, const std::string& message) = 0; 114 virtual void status(S32 code, const std::string& message) = 0;
107 115
108 /** 116 /**
109 * @brief Return no body, just status code and 'UNKNOWN ERROR'. 117 * @brief Return no body, just status code and 'UNKNOWN ERROR'.
110 */ 118 */
111 void status(S32 code); 119 virtual void status(S32 code);
112 120
113 void notFound(const std::string& message); 121 virtual void notFound(const std::string& message);
114 void notFound(); 122 virtual void notFound();
115 void methodNotAllowed(); 123 virtual void methodNotAllowed();
116 124
117 /** 125 /**
118 * @breif Add a name: value http header. 126 * @breif Add a name: value http header.
119 * 127 *
120 * No effort is made to ensure the response is a valid http 128 * No effort is made to ensure the response is a valid http
121 * header. 129 * header.
122 * The headers are stored as a map of header name : value. 130 * The headers are stored as a map of header name : value.
123 * Though HTTP allows the same header name to be transmitted 131 * Though HTTP allows the same header name to be transmitted
124 * more than once, this implementation only stores a header 132 * more than once, this implementation only stores a header
125 * name once. 133 * name once.
126 * @param name The name of the header, eg, "Content-Encoding" 134 * @param name The name of the header, eg, "Content-Encoding"
127 * @param value The value of the header, eg, "gzip" 135 * @param value The value of the header, eg, "gzip"
128 */ 136 */
129 void addHeader(const std::string& name, const std::string& value); 137 virtual void addHeader(const std::string& name, const std::string& value);
130 138
131 protected: 139 protected:
132 /** 140 /**
133 * @brief Headers to be sent back with the HTTP response. 141 * @brief Headers to be sent back with the HTTP response.
134 * 142 *
135 * Protected class membership since derived classes are 143 * Protected class membership since derived classes are
136 * expected to use it and there is no use case yet for other 144 * expected to use it and there is no use case yet for other
137 * uses. If such a use case arises, I suggest making a 145 * uses. If such a use case arises, I suggest making a
138 * headers() public method, and moving this member data into 146 * headers() public method, and moving this member data into
139 * private. 147 * private.
140 */ 148 */
141 LLSD mHeaders; 149 LLSD mHeaders;
142 }; 150 };
143 151
144
145 typedef LLPointer<Response> ResponsePtr; 152 typedef LLPointer<Response> ResponsePtr;
146 153
147 virtual void get(ResponsePtr, const LLSD& context) const; 154 virtual void get(ResponsePtr, const LLSD& context) const;
@@ -217,6 +224,14 @@ public:
217 const LLHTTPNode* rootNode() const; 224 const LLHTTPNode* rootNode() const;
218 const LLHTTPNode* findNode(const std::string& name) const; 225 const LLHTTPNode* findNode(const std::string& name) const;
219 226
227
228 enum EHTTPNodeContentType
229 {
230 CONTENT_TYPE_LLSD,
231 CONTENT_TYPE_TEXT
232 };
233
234 virtual EHTTPNodeContentType getContentType() const { return CONTENT_TYPE_LLSD; }
220 //@} 235 //@}
221 236
222 /* @name Description system 237 /* @name Description system
@@ -276,6 +291,7 @@ public:
276 static LLPointer<LLSimpleResponse> create(); 291 static LLPointer<LLSimpleResponse> create();
277 292
278 void result(const LLSD& result); 293 void result(const LLSD& result);
294 void extendedResult(S32 code, const std::string& body, const LLSD& headers);
279 void status(S32 code, const std::string& message); 295 void status(S32 code, const std::string& message);
280 296
281 void print(std::ostream& out) const; 297 void print(std::ostream& out) const;