8#ifndef _NIM_TOOLS_SDK_CPP_HTTP_H_
9#define _NIM_TOOLS_SDK_CPP_HTTP_H_
41typedef std::function<void(
bool,
int,
const std::string&,
const std::string&)>
ResponseCallbackEx;
72bool Init(
const std::string& library_path =
"");
85void InitLog(
const std::string& log_file_path);
141 const std::string& download_file_path,
159 const std::string& download_file_path,
178 const char* post_body,
179 size_t post_body_size,
197 const char* post_body,
198 size_t post_body_size,
210 void AddHeader(
const std::string& key,
const std::string& value);
217 void AddHeader(
const std::map<std::string, std::string>& headers_map);
238 void SetLowSpeed(
int low_speed_limit,
int low_speed_time);
249 void SetProxy(
NIMProxyType type,
const std::string& host,
short port,
const std::string& user,
const std::string& pass);
252 static void CompletedCallbackWrapper(
const void* user_data,
bool is_ok,
int response_code);
253 static void ResponseCallbackWrapper(
const void* user_data,
bool is_ok,
int response_code,
const char* content,
const char* head);
254 static void ProgressCallbackWrapper(
const void* user_data,
256 double uploaded_size,
257 double download_size,
258 double downloaded_size);
259 static void SpeedCallbackWrapper(
const void* user_data,
double upload_speed,
double download_speed);
260 static void TransferCallbackWrapper(
const void* user_data,
261 double actual_upload_size,
263 double actual_download_size,
264 double download_speed);
NIM HTTP提供的http传输相关接口
Definition: nim_tools_http_cpp.h:128
void SetTimeout(int timeout_ms)
Definition: nim_tools_http_cpp.cpp:406
void SetMethodAsPost()
Definition: nim_tools_http_cpp.cpp:402
void SetLowSpeed(int low_speed_limit, int low_speed_time)
Definition: nim_tools_http_cpp.cpp:410
void AddHeader(const std::string &key, const std::string &value)
Definition: nim_tools_http_cpp.cpp:392
void SetProxy(NIMProxyType type, const std::string &host, short port, const std::string &user, const std::string &pass)
Definition: nim_tools_http_cpp.cpp:414
HttpRequest(const std::string &url, const std::string &download_file_path, const CompletedCallback &complete_cb, const ProgressCallback &progress_cb=ProgressCallback(), const SpeedCallback &speed_cb=SpeedCallback(), const TransferCallback &transfer_cb=TransferCallback())
Definition: nim_tools_http_cpp.cpp:221
NIM提供的HTTP工具
Definition: nim_tools_http_cpp.cpp:16
HttpRequestID PostRequest(const HttpRequest &http_request)
Definition: nim_tools_http_cpp.cpp:208
std::function< void(double, double, double, double)> ProgressCallback
Definition: nim_tools_http_cpp.h:49
bool IsInitLog()
Definition: nim_tools_http_cpp.cpp:190
void RemoveRequest(HttpRequestID http_request_id)
Definition: nim_tools_http_cpp.cpp:212
std::function< void(bool, int, const std::string &, const std::string &)> ResponseCallbackEx
Definition: nim_tools_http_cpp.h:41
std::function< void(double, double, double, double)> TransferCallback
Definition: nim_tools_http_cpp.h:63
std::function< void(bool, int, const std::string &)> ResponseCallback
Definition: nim_tools_http_cpp.h:33
std::function< void(double, double)> SpeedCallback
Definition: nim_tools_http_cpp.h:55
void SetGlobalProxy(NIMProxyType type, const std::string &host, short port, const std::string &user, const std::string &pass)
Definition: nim_tools_http_cpp.cpp:200
void InitLog(const std::string &log_file_path)
Definition: nim_tools_http_cpp.cpp:186
void Uninit()
Definition: nim_tools_http_cpp.cpp:179
std::function< void(bool, int)> CompletedCallback
Definition: nim_tools_http_cpp.h:26
std::string GetResponseHead(HttpRequestID http_request_id)
Definition: nim_tools_http_cpp.cpp:215
NIMProxyType
Definition: nim_global_def.h:186