NIM 跨平台 C++ SDK
载入中...
搜索中...
未找到
nim_http 命名空间参考

NIM提供的HTTP工具 更多...

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

类型定义

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
 

函数

bool Init (const std::string &library_path)
 
void Uninit ()
 
void InitLog (const std::string &log_file_path)
 
bool IsInitLog ()
 
void SetGlobalProxy (nim::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)
 

变量

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
 
nim::NIMProxyType proxy_type_ = nim::kNIMProxyNone
 
std::string proxy_host_
 
short proxy_port_ = 0
 
std::string proxy_user_
 
std::string proxy_pass_
 

详细描述

NIM提供的HTTP工具

类型定义说明

◆ CompletedCallback

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

请求完成回调

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

◆ ProgressCallback

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

请求过程回调

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

◆ ResponseCallback

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

请求响应回调

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

◆ ResponseCallbackEx

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

请求响应回调

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

◆ SpeedCallback

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

请求速度回报回调

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

◆ TransferCallback

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

请求汇报回调

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

◆ typeof_nim_http_add_request_header

typedef void(* nim_http::typeof_nim_http_add_request_header) (HttpRequestHandle request_handle, const char *key, const char *value)

◆ typeof_nim_http_create_download_file_range_request

typedef HttpRequestHandle(* nim_http::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)

◆ typeof_nim_http_create_download_file_request

typedef HttpRequestHandle(* nim_http::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)

◆ typeof_nim_http_create_request

typedef HttpRequestHandle(* nim_http::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)

◆ typeof_nim_http_create_request_ex

typedef HttpRequestHandle(* nim_http::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)

◆ typeof_nim_http_get_response_head

typedef const char *const (* nim_http::typeof_nim_http_get_response_head) (HttpRequestID http_request_id)

◆ typeof_nim_http_init

typedef void(* nim_http::typeof_nim_http_init) ()

◆ typeof_nim_http_init_log

typedef void(* nim_http::typeof_nim_http_init_log) (const char *log_file_path)

◆ typeof_nim_http_is_init_log

typedef bool(* nim_http::typeof_nim_http_is_init_log) ()

◆ typeof_nim_http_post_request

typedef HttpRequestID(* nim_http::typeof_nim_http_post_request) (HttpRequestHandle)

◆ typeof_nim_http_remove_request

typedef void(* nim_http::typeof_nim_http_remove_request) (HttpRequestID http_request_id)

◆ typeof_nim_http_set_low_speed

typedef void(* nim_http::typeof_nim_http_set_low_speed) (HttpRequestHandle request_handle, int low_speed_limit, int low_speed_time)

◆ typeof_nim_http_set_proxy

typedef void( * nim_http::typeof_nim_http_set_proxy) (HttpRequestHandle request_handle, int type, const char *host, short port, const char *user, const char *pass)

◆ typeof_nim_http_set_request_method_as_post

typedef void(* nim_http::typeof_nim_http_set_request_method_as_post) (HttpRequestHandle request_handle)

◆ typeof_nim_http_set_request_progress_cb

typedef void(* nim_http::typeof_nim_http_set_request_progress_cb) (HttpRequestHandle request_handle, nim_http_request_progress_cb progress_callback, const void *user_data)

◆ typeof_nim_http_set_request_speed_cb

typedef void( * nim_http::typeof_nim_http_set_request_speed_cb) (HttpRequestHandle request_handle, nim_http_request_speed_cb speed_callback, const void *user_data)

◆ typeof_nim_http_set_request_transfer_cb

typedef void(* nim_http::typeof_nim_http_set_request_transfer_cb) (HttpRequestHandle request_handle, nim_http_request_transfer_cb transfer_callback, const void *user_data)

◆ typeof_nim_http_set_timeout

typedef void(* nim_http::typeof_nim_http_set_timeout) (HttpRequestHandle request_handle, int timeout_ms)

◆ typeof_nim_http_uninit

typedef void(* nim_http::typeof_nim_http_uninit) ()

函数说明

◆ GetResponseHead()

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

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

参数
[in]http_request_id任务id
返回
std::string HTTP应答头信息

◆ Init()

bool nim_http::Init ( const std::string &  library_path)

◆ InitLog()

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

NIM HTTP 设置日志文件路径

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

◆ IsInitLog()

bool nim_http::IsInitLog ( )

NIM HTTP 是否设置过日志路径

返回
bool 是否设置过日志路径

◆ PostRequest()

HttpRequestID nim_http::PostRequest ( const HttpRequest http_request)

NIM HTTP 发起任务

参数
[in]http_requesthttp任务句柄
返回
HttpRequestID 任务id

◆ RemoveRequest()

void nim_http::RemoveRequest ( HttpRequestID  http_request_id)

NIM HTTP 取消任务

参数
[in]http_request_id任务id
返回
void 无返回值

◆ SetGlobalProxy()

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

◆ Uninit()

void nim_http::Uninit ( )

NIM HTTP 反初始化

返回
void 无返回值

变量说明

◆ g_nim_http_add_request_header

typeof_nim_http_add_request_header nim_http::g_nim_http_add_request_header = nullptr

◆ g_nim_http_create_download_file_range_request

typeof_nim_http_create_download_file_range_request nim_http::g_nim_http_create_download_file_range_request = nullptr

◆ g_nim_http_create_download_file_request

typeof_nim_http_create_download_file_request nim_http::g_nim_http_create_download_file_request = nullptr

◆ g_nim_http_create_request

typeof_nim_http_create_request nim_http::g_nim_http_create_request = nullptr

◆ g_nim_http_create_request_ex

typeof_nim_http_create_request_ex nim_http::g_nim_http_create_request_ex = nullptr

◆ g_nim_http_get_response_head

typeof_nim_http_get_response_head nim_http::g_nim_http_get_response_head = nullptr

◆ g_nim_http_init

typeof_nim_http_init nim_http::g_nim_http_init = nullptr

◆ g_nim_http_init_log

typeof_nim_http_init_log nim_http::g_nim_http_init_log = nullptr

◆ g_nim_http_is_init_log

typeof_nim_http_is_init_log nim_http::g_nim_http_is_init_log = nullptr

◆ g_nim_http_post_request

typeof_nim_http_post_request nim_http::g_nim_http_post_request = nullptr

◆ g_nim_http_remove_request

typeof_nim_http_remove_request nim_http::g_nim_http_remove_request = nullptr

◆ g_nim_http_set_low_speed

typeof_nim_http_set_low_speed nim_http::g_nim_http_set_low_speed = nullptr

◆ g_nim_http_set_proxy

typeof_nim_http_set_proxy nim_http::g_nim_http_set_proxy = nullptr

◆ g_nim_http_set_request_method_as_post

typeof_nim_http_set_request_method_as_post nim_http::g_nim_http_set_request_method_as_post = nullptr

◆ g_nim_http_set_request_progress_cb

typeof_nim_http_set_request_progress_cb nim_http::g_nim_http_set_request_progress_cb = nullptr

◆ g_nim_http_set_request_speed_cb

typeof_nim_http_set_request_speed_cb nim_http::g_nim_http_set_request_speed_cb = nullptr

◆ g_nim_http_set_request_transfer_cb

typeof_nim_http_set_request_transfer_cb nim_http::g_nim_http_set_request_transfer_cb = nullptr

◆ g_nim_http_set_timeout

typeof_nim_http_set_timeout nim_http::g_nim_http_set_timeout = nullptr

◆ g_nim_http_uninit

typeof_nim_http_uninit nim_http::g_nim_http_uninit = nullptr

◆ proxy_host_

std::string nim_http::proxy_host_

◆ proxy_pass_

std::string nim_http::proxy_pass_

◆ proxy_port_

short nim_http::proxy_port_ = 0

◆ proxy_type_

nim::NIMProxyType nim_http::proxy_type_ = nim::kNIMProxyNone

◆ proxy_user_

std::string nim_http::proxy_user_

◆ sdk_instance_

nim::SDKInstance* nim_http::sdk_instance_ = nullptr