diff options
author | McCabe Maxsted | 2010-07-07 11:40:20 -0700 |
---|---|---|
committer | McCabe Maxsted | 2010-07-07 11:40:20 -0700 |
commit | 35eaded540f31378845b7a88e212a86a68825040 (patch) | |
tree | 05a91e33fe0de6afa555afa2c350b889e770bbcb /linden/indra/newview/hippoRestRequest.h | |
parent | Cleaned up the grid manager layout some (diff) | |
download | meta-impy-35eaded540f31378845b7a88e212a86a68825040.zip meta-impy-35eaded540f31378845b7a88e212a86a68825040.tar.gz meta-impy-35eaded540f31378845b7a88e212a86a68825040.tar.bz2 meta-impy-35eaded540f31378845b7a88e212a86a68825040.tar.xz |
Updated hipporestrequest code to hippo 0.6.3
Diffstat (limited to 'linden/indra/newview/hippoRestRequest.h')
-rw-r--r-- | linden/indra/newview/hippoRestRequest.h | 98 |
1 files changed, 93 insertions, 5 deletions
diff --git a/linden/indra/newview/hippoRestRequest.h b/linden/indra/newview/hippoRestRequest.h index 1dcb4a0..727dbf7 100644 --- a/linden/indra/newview/hippoRestRequest.h +++ b/linden/indra/newview/hippoRestRequest.h | |||
@@ -1,15 +1,103 @@ | |||
1 | #ifndef __HIPPO_REST_REQTUEST_H__ | 1 | #ifndef __HIPPO_REST_REQUEST_H__ |
2 | #define __HIPPO_REST_REQTUEST_H__ | 2 | #define __HIPPO_REST_REQUEST_H__ |
3 | 3 | ||
4 | 4 | ||
5 | #include <map> | ||
5 | #include <string> | 6 | #include <string> |
6 | 7 | ||
8 | #include <boost/shared_ptr.hpp> | ||
9 | |||
10 | class LLBufferArray; | ||
11 | class LLChannelDescriptors; | ||
12 | class LLXmlTree; | ||
13 | |||
14 | |||
15 | #define HIPPO_REST_TIMEOUT 60.f | ||
16 | |||
17 | |||
18 | // ******************************************************************** | ||
19 | |||
20 | |||
21 | class HippoRestHandler | ||
22 | { | ||
23 | public: | ||
24 | virtual ~HippoRestHandler() { } | ||
25 | |||
26 | virtual const char *getAcceptMimeType() const = 0; | ||
27 | |||
28 | bool hasHeader(const std::string &header) const; | ||
29 | const std::string &getHeader(const std::string &header) const; | ||
30 | |||
31 | private: | ||
32 | // These functions are called by the request engine | ||
33 | void addHeader(const std::string &header, const std::string &content); | ||
34 | virtual void handle(int status, const std::string &reason, | ||
35 | const LLChannelDescriptors &channels, | ||
36 | const boost::shared_ptr<LLBufferArray> &body) = 0; | ||
37 | |||
38 | std::map<std::string, std::string> mHeaders; | ||
39 | |||
40 | friend class HippoRestComplete; | ||
41 | }; | ||
42 | |||
43 | |||
44 | class HippoRestHandlerRaw : public HippoRestHandler | ||
45 | { | ||
46 | public: | ||
47 | virtual ~HippoRestHandlerRaw() { } | ||
48 | |||
49 | const char *getAcceptMimeType() const { return "application/octet-stream"; } | ||
50 | |||
51 | private: | ||
52 | // This function must be implemented to receive the content | ||
53 | // it is executed on (status == 200) only | ||
54 | virtual void result(const std::string &content) = 0; | ||
55 | |||
56 | // This function is called by the request engine | ||
57 | void handle(int status, const std::string &reason, | ||
58 | const LLChannelDescriptors &channels, | ||
59 | const boost::shared_ptr<LLBufferArray> &body); | ||
60 | }; | ||
61 | |||
62 | |||
63 | class HippoRestHandlerXml : public HippoRestHandler | ||
64 | { | ||
65 | public: | ||
66 | virtual ~HippoRestHandlerXml() { } | ||
67 | |||
68 | const char *getAcceptMimeType() const { return "application/xml"; } | ||
69 | |||
70 | private: | ||
71 | // This function must be implemented to receive the content | ||
72 | virtual void result(LLXmlTree *content) = 0; | ||
73 | |||
74 | // This function is called by the request engine | ||
75 | void handle(int status, const std::string &reason, | ||
76 | const LLChannelDescriptors &channels, | ||
77 | const boost::shared_ptr<LLBufferArray> &body); | ||
78 | }; | ||
79 | |||
80 | |||
81 | // ******************************************************************** | ||
82 | |||
7 | 83 | ||
8 | class HippoRestRequest | 84 | class HippoRestRequest |
9 | { | 85 | { |
10 | public: | 86 | public: |
11 | static int getBlocking(const std::string &url, std::string *result); | 87 | // asynchronous interface |
12 | 88 | static void get(const std::string &url, | |
89 | HippoRestHandler *handler, float timeout=HIPPO_REST_TIMEOUT); | ||
90 | static void put(const std::string &url, const std::string &body, | ||
91 | HippoRestHandler *handler, float timeout=HIPPO_REST_TIMEOUT); | ||
92 | static void put(const std::string &url, const LLXmlTree *body, | ||
93 | HippoRestHandler *handler, float timeout=HIPPO_REST_TIMEOUT); | ||
94 | static void post(const std::string &url, const std::string &body, | ||
95 | HippoRestHandler *handler, float timeout=HIPPO_REST_TIMEOUT); | ||
96 | static void post(const std::string &url, const LLXmlTree *body, | ||
97 | HippoRestHandler *handler, float timeout=HIPPO_REST_TIMEOUT); | ||
98 | |||
99 | // synchronous interface | ||
100 | static int getBlocking(const std::string &url, std::string *result); | ||
13 | }; | 101 | }; |
14 | 102 | ||
15 | 103 | ||