#ifndef CHROMECAST_CRASH_LIBCURL_WRAPPER_H_
#define CHROMECAST_CRASH_LIBCURL_WRAPPER_H_
#include <map>
#include <string>
#include "third_party/breakpad/breakpad/src/third_party/curl/curl.h"
namespace chromecast {
class LibcurlWrapper {
public:
LibcurlWrapper();
virtual ~LibcurlWrapper();
virtual bool Init();
virtual bool AddFile(const std::string& upload_file_path,
const std::string& basename);
virtual bool SendRequest(const std::string& url,
const std::map<std::string, std::string>& parameters,
long* http_status_code,
std::string* http_header_data,
std::string* http_response_data);
private:
bool SetFunctionPointers();
bool SendRequestInner(const std::string& url,
long* http_status_code,
std::string* http_header_data,
std::string* http_response_data);
void Reset();
bool CheckInit();
bool init_ok_;
void* curl_lib_;
std::string last_curl_error_;
CURL* curl_;
CURL* (*easy_init_)(void);
struct curl_httppost* formpost_;
struct curl_httppost* lastptr_;
struct curl_slist* headerlist_;
CURLcode (*easy_setopt_)(CURL*, CURLoption, ...);
CURLFORMcode (*formadd_)(struct curl_httppost**, struct curl_httppost**, ...);
struct curl_slist* (*slist_append_)(struct curl_slist*, const char*);
void (*slist_free_all_)(struct curl_slist*);
CURLcode (*easy_perform_)(CURL*);
const char* (*easy_strerror_)(CURLcode);
void (*easy_cleanup_)(CURL*);
CURLcode (*easy_getinfo_)(CURL*, CURLINFO info, ...);
void (*easy_reset_)(CURL*);
void (*formfree_)(struct curl_httppost*);
};
}
#endif