Files
@ 1209b439451e
Branch filter:
Location: libtransport.git/include/transport/HTTPRequest.h - annotation
1209b439451e
1.5 KiB
text/plain
libpurple: prefer serialized room name as room id
* should fix room join problems with multiple third-party purple plugins
* should fix room join problems with multiple third-party purple plugins
5adb3d1f9733 5adb3d1f9733 3e75beb9548c 3e75beb9548c 3e75beb9548c 5adb3d1f9733 3e75beb9548c 3e75beb9548c 3e75beb9548c 19106c7ec482 3e75beb9548c ce2218d0864b 5adb3d1f9733 3e75beb9548c 3e75beb9548c 5adb3d1f9733 3e75beb9548c 5adb3d1f9733 19106c7ec482 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 3e75beb9548c 5dd1aa90b4c0 3e75beb9548c 3e75beb9548c 5adb3d1f9733 19106c7ec482 5adb3d1f9733 b88294238340 b88294238340 b88294238340 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 eb8f7ddad957 eb8f7ddad957 eb8f7ddad957 eb8f7ddad957 ce2218d0864b 3e75beb9548c 1e48fe771986 1e48fe771986 1e48fe771986 1e48fe771986 1e48fe771986 1e48fe771986 1e48fe771986 1e48fe771986 3e75beb9548c 3e75beb9548c 5adb3d1f9733 19106c7ec482 5adb3d1f9733 3e75beb9548c 3e75beb9548c 3e75beb9548c 3e75beb9548c 3e75beb9548c 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 19106c7ec482 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 3e75beb9548c 3e75beb9548c 3e75beb9548c 3e75beb9548c 3e75beb9548c 3e75beb9548c 3e75beb9548c |
#pragma once
#include "curl/curl.h"
#include "transport/Logging.h"
#include "transport/ThreadPool.h"
#include <iostream>
#include <sstream>
#include <string.h>
#include <json/json.h>
#include <Swiften/SwiftenCompat.h>
namespace Transport {
class HTTPRequest : public Thread {
public:
typedef enum { Get } Type;
typedef boost::function< void (HTTPRequest *, bool, Json::Value &json, const std::string &data) > Callback;
HTTPRequest(ThreadPool *tp, Type type, const std::string &url, Callback callback);
HTTPRequest(Type type, const std::string &url);
virtual ~HTTPRequest();
void setProxy(std::string, std::string, std::string, std::string);
bool execute();
bool execute(Json::Value &json);
std::string getError() {return std::string(curl_errorbuffer);}
const std::string &getRawData() {
return m_data;
}
void run();
void finalize();
const std::string &getURL() {
return m_url;
}
SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onRequestFinished;
static void globalInit() {
curl_global_init(CURL_GLOBAL_ALL);
}
static void globalCleanup() {
curl_global_cleanup();
}
private:
bool init();
bool GET(std::string url, std::string &output);
bool GET(std::string url, Json::Value &json);
CURL *curlhandle;
char curl_errorbuffer[1024];
std::string error;
std::string callbackdata;
ThreadPool *m_tp;
std::string m_url;
bool m_ok;
Json::Value m_json;
std::string m_data;
Callback m_callback;
Type m_type;
static int curlCallBack(char* data, size_t size, size_t nmemb, HTTPRequest *obj);
};
}
|