NIM PC Cross Platform SDK
nim_http Namespace Reference

NIM提供的HTTP工具 More...

Classes

struct  CompletedCallbackUserData
 
class  HttpRequest
 NIM HTTP提供的http传输相关接口 More...
 
struct  ResponseCallbackUserData
 

Typedefs

typedef void(* typeof_nim_http_init) ()
 
typedef void(* typeof_nim_http_uninit) ()
 
typedef void(* typeof_nim_http_init_log) (const char *log_file_path)
 
typedef bool(* typeof_nim_http_is_init_log) ()
 
typedef HttpRequestHandle(* typeof_nim_http_create_download_file_request) (const char *url, const char *download_file_path, nim_http_request_completed_cb complete_cb, const void *user_data)
 
typedef HttpRequestHandle(* typeof_nim_http_create_download_file_range_request) (const char *url, const char *download_file_path, int64_t range_start, nim_http_request_completed_cb complete_cb, const void *user_data)
 
typedef HttpRequestHandle(* typeof_nim_http_create_request) (const char *url, const char *post_body, size_t post_body_size, nim_http_request_response_cb response_cb, const void *user_data)
 
typedef HttpRequestHandle(* typeof_nim_http_create_request_ex) (const char *url, const char *post_body, size_t post_body_size, nim_http_request_response_ex_cb response_cb, const void *user_data)
 
typedef void(* typeof_nim_http_add_request_header) (HttpRequestHandle request_handle, const char *key, const char *value)
 
typedef void(* typeof_nim_http_set_request_progress_cb) (HttpRequestHandle request_handle, nim_http_request_progress_cb progress_callback, const void *user_data)
 
typedef void(* typeof_nim_http_set_request_speed_cb) (HttpRequestHandle request_handle, nim_http_request_speed_cb speed_callback, const void *user_data)
 
typedef void(* typeof_nim_http_set_request_transfer_cb) (HttpRequestHandle request_handle, nim_http_request_transfer_cb transfer_callback, const void *user_data)
 
typedef void(* typeof_nim_http_set_request_method_as_post) (HttpRequestHandle request_handle)
 
typedef void(* typeof_nim_http_set_timeout) (HttpRequestHandle request_handle, int timeout_ms)
 
typedef void(* typeof_nim_http_set_low_speed) (HttpRequestHandle request_handle, int low_speed_limit, int low_speed_time)
 
typedef void(* typeof_nim_http_set_proxy) (HttpRequestHandle request_handle, int type, const char *host, short port, const char *user, const char *pass)
 
typedef HttpRequestID(* typeof_nim_http_post_request) (HttpRequestHandle)
 
typedef void(* typeof_nim_http_remove_request) (HttpRequestID http_request_id)
 
typedef const char *const(* typeof_nim_http_get_response_head) (HttpRequestID http_request_id)
 
typedef std::function< void(bool, int)> CompletedCallback
 
typedef std::function< void(bool, int, const std::string &)> ResponseCallback
 
typedef std::function< void(bool, int, const std::string &, const std::string &)> ResponseCallbackEx
 
typedef std::function< void(double, double, double, double)> ProgressCallback
 
typedef std::function< void(double, double)> SpeedCallback
 
typedef std::function< void(double, double, double, double)> TransferCallback
 

Functions

bool Init (const std::string &library_path)
 
void Uninit ()
 
void InitLog (const std::string &log_file_path)
 
bool IsInitLog ()
 
void SetGlobalProxy (NIMProxyType type, const std::string &host, short port, const std::string &user, const std::string &pass)
 
HttpRequestID PostRequest (const HttpRequest &http_request)
 
void RemoveRequest (HttpRequestID http_request_id)
 
std::string GetResponseHead (HttpRequestID http_request_id)
 

Variables

nim::SDKInstancesdk_instance_ = nullptr
 
typeof_nim_http_init g_nim_http_init = nullptr
 
typeof_nim_http_uninit g_nim_http_uninit = nullptr
 
typeof_nim_http_init_log g_nim_http_init_log = nullptr
 
typeof_nim_http_is_init_log g_nim_http_is_init_log = nullptr
 
typeof_nim_http_create_download_file_request g_nim_http_create_download_file_request = nullptr
 
typeof_nim_http_create_download_file_range_request g_nim_http_create_download_file_range_request = nullptr
 
typeof_nim_http_create_request g_nim_http_create_request = nullptr
 
typeof_nim_http_create_request_ex g_nim_http_create_request_ex = nullptr
 
typeof_nim_http_add_request_header g_nim_http_add_request_header = nullptr
 
typeof_nim_http_set_request_progress_cb g_nim_http_set_request_progress_cb = nullptr
 
typeof_nim_http_set_request_speed_cb g_nim_http_set_request_speed_cb = nullptr
 
typeof_nim_http_set_request_transfer_cb g_nim_http_set_request_transfer_cb = nullptr
 
typeof_nim_http_set_request_method_as_post g_nim_http_set_request_method_as_post = nullptr
 
typeof_nim_http_set_timeout g_nim_http_set_timeout = nullptr
 
typeof_nim_http_set_low_speed g_nim_http_set_low_speed = nullptr
 
typeof_nim_http_set_proxy g_nim_http_set_proxy = nullptr
 
typeof_nim_http_post_request g_nim_http_post_request = nullptr
 
typeof_nim_http_remove_request g_nim_http_remove_request = nullptr
 
typeof_nim_http_get_response_head g_nim_http_get_response_head = nullptr
 
NIMProxyType proxy_type_ = kNIMProxyNone
 
std::string proxy_host_
 
short proxy_port_ = 0
 
std::string proxy_user_
 
std::string proxy_pass_
 

Detailed Description

NIM提供的HTTP工具

Typedef Documentation

◆ CompletedCallback

typedef std::function<void(bool, int)> nim_http::CompletedCallback

请求完成回调

Parameters
[out]传输结果,true代表传输成功,false代表传输失败
[out]http响应码

◆ ProgressCallback

typedef std::function<void(double, double, double, double)> nim_http::ProgressCallback

请求过程回调

Parameters
[out]总的待上传字节数
[out]当前上传字节数
[out]总的待下载字节数
[out]当前下载字节数

◆ ResponseCallback

typedef std::function<void(bool, int, const std::string&)> nim_http::ResponseCallback

请求响应回调

Parameters
[out]传输结果,true代表传输成功,false代表传输失败
[out]http响应码
[out]http响应实体内容

◆ ResponseCallbackEx

typedef std::function<void(bool, int, const std::string&, const std::string&)> nim_http::ResponseCallbackEx

请求响应回调

Parameters
[out]传输结果,true代表传输成功,false代表传输失败
[out]http响应码
[out]http响应实体内容
[out]http响应Head内容

◆ SpeedCallback

typedef std::function<void(double, double)> nim_http::SpeedCallback

请求速度回报回调

Parameters
[out]实时上传速度(字节每秒)
[out]实时下载速度(字节每秒)

◆ TransferCallback

typedef std::function<void(double, double, double, double)> nim_http::TransferCallback

请求汇报回调

Parameters
[out]实际上传字节数
[out]平均上传速度(字节每秒)
[out]实际下载字节数
[out]平均下载速度(字节每秒)

Function Documentation

◆ GetResponseHead()

std::string nim_http::GetResponseHead ( HttpRequestID  http_request_id)

NIM HTTP 读取应答的http头信息,在任务完成的回调中调用,当回调完成后应答可能被释放,此时无法读取信息

Parameters
[in]http_request_id任务id
Returns
std::string HTTP应答头信息

◆ InitLog()

void nim_http::InitLog ( const std::string &  log_file_path)

NIM HTTP 设置日志文件路径

Parameters
[in]log_file_path日志文件保存路径
Returns
void 无返回值

◆ IsInitLog()

bool nim_http::IsInitLog ( )

NIM HTTP 是否设置过日志路径

Returns
bool 是否设置过日志路径

◆ PostRequest()

HttpRequestID nim_http::PostRequest ( const HttpRequest http_request)

NIM HTTP 发起任务

Parameters
[in]http_requesthttp任务句柄
Returns
HttpRequestID 任务id

◆ RemoveRequest()

void nim_http::RemoveRequest ( HttpRequestID  http_request_id)

NIM HTTP 取消任务

Parameters
[in]http_request_id任务id
Returns
void 无返回值

◆ SetGlobalProxy()

void nim_http::SetGlobalProxy ( NIMProxyType  type,
const std::string &  host,
short  port,
const std::string &  user,
const std::string &  pass 
)

NIM HTTP 设置cpp封装层的全局代理

Parameters
[in]type代理类型NIMProxyType
[in]host代理地址
[in]port代理端口
[in]user代理账号
[in]pass代理密码
Returns
void

◆ Uninit()

void nim_http::Uninit ( )

NIM HTTP 反初始化

Returns
void 无返回值