00001
00032 #ifndef LL_LLHTTPCLIENT_H
00033 #define LL_LLHTTPCLIENT_H
00034
00039 #include <string>
00040
00041 #include <boost/intrusive_ptr.hpp>
00042
00043 #include "llassettype.h"
00044 #include "llbuffer.h"
00045 #include "lliopipe.h"
00046
00047 extern const F32 HTTP_REQUEST_EXPIRY_SECS;
00048
00049 class LLUUID;
00050 class LLPumpIO;
00051 class LLSD;
00052
00053
00054 class LLHTTPClient
00055 {
00056 public:
00057 class Responder
00058 {
00059 public:
00060 Responder();
00061 virtual ~Responder();
00062
00066 static bool isGoodStatus(U32 status)
00067 {
00068 return((200 <= status) && (status < 300));
00069 }
00070
00071 virtual void error(U32 status, const std::string& reason);
00072
00073 virtual void result(const LLSD& content);
00074
00075
00076 virtual void completedRaw(U32 status, const std::string& reason, const LLChannelDescriptors& channels,
00077 const LLIOPipe::buffer_ptr_t& buffer);
00078
00079 virtual void completed(U32 status, const std::string& reason, const LLSD& content);
00086 public:
00087 U32 mReferenceCount;
00088 };
00089
00090 typedef boost::intrusive_ptr<Responder> ResponderPtr;
00091
00092 static void get(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
00093 static void get(const std::string& url, ResponderPtr, const LLSD& headers, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
00094 static void get(const std::string& url, const LLSD& query, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
00095 static void get(const std::string& url, const LLSD& query, ResponderPtr, const LLSD& headers, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
00096 static void put(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
00098 static void post(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
00099 static void post(const std::string& url, const U8* data, S32 size, ResponderPtr responder, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
00100 static void postFile(const std::string& url, const std::string& filename, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
00101 static void postFile(const std::string& url, const LLUUID& uuid,
00102 LLAssetType::EType asset_type, ResponderPtr responder, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
00103
00104
00105 static LLSD blockingGet(const std::string& url);
00106
00107 static void del(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
00109
00110
00111 static void setPump(LLPumpIO& pump);
00113 static bool hasPump();
00115
00116 static void setCABundle(const std::string& caBundle);
00120 };
00121
00122
00123
00124 namespace boost
00125 {
00126 void intrusive_ptr_add_ref(LLHTTPClient::Responder* p);
00127 void intrusive_ptr_release(LLHTTPClient::Responder* p);
00128 };
00129
00130
00131 #endif // LL_LLHTTPCLIENT_H