NIM 跨平台 C++ SDK
载入中...
搜索中...
未找到
nim_http::HttpRequest类 参考

NIM HTTP提供的http传输相关接口 更多...

#include <nim_tools_http_cpp.h>

Public 成员函数

 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())
 
 HttpRequest (const std::string &url, const std::string &download_file_path, int64_t range_start, const CompletedCallback &complete_cb, const ProgressCallback &progress_cb=ProgressCallback(), const SpeedCallback &speed_cb=SpeedCallback(), const TransferCallback &transfer_cb=TransferCallback())
 
 HttpRequest (const std::string &url, const char *post_body, size_t post_body_size, const ResponseCallback &response_cb, const ProgressCallback &progress_cb=ProgressCallback(), const SpeedCallback &speed_cb=SpeedCallback(), const TransferCallback &transfer_cb=TransferCallback())
 
 HttpRequest (const std::string &url, const char *post_body, size_t post_body_size, const ResponseCallbackEx &response_cb, const ProgressCallback &progress_cb=ProgressCallback(), const SpeedCallback &speed_cb=SpeedCallback(), const TransferCallback &transfer_cb=TransferCallback())
 
void AddHeader (const std::string &key, const std::string &value)
 
void AddHeader (const std::map< std::string, std::string > &headers_map)
 
void SetMethodAsPost ()
 
void SetTimeout (int timeout_ms)
 
void SetLowSpeed (int low_speed_limit, int low_speed_time)
 
void SetProxy (nim::NIMProxyType type, const std::string &host, short port, const std::string &user, const std::string &pass)
 

静态 Private 成员函数

static void CompletedCallbackWrapper (const void *user_data, bool is_ok, int response_code)
 
static void ResponseCallbackWrapper (const void *user_data, bool is_ok, int response_code, const char *content, const char *head)
 
static void ProgressCallbackWrapper (const void *user_data, double upload_size, double uploaded_size, double download_size, double downloaded_size)
 
static void SpeedCallbackWrapper (const void *user_data, double upload_speed, double download_speed)
 
static void TransferCallbackWrapper (const void *user_data, double actual_upload_size, double upload_speed, double actual_download_size, double download_speed)
 

Private 属性

HttpRequestHandle http_reuqest_handle_
 

友元

HttpRequestID PostRequest (const HttpRequest &http_request)
 

详细描述

NIM HTTP提供的http传输相关接口

构造及析构函数说明

◆ HttpRequest() [1/4]

nim_http::HttpRequest::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() 
)

NIM HTTP 创建下载文件任务

参数
[in]url资源地址
[in]download_file_path下载文件保存的本地路径
[in]complete_cb结束回调
[in]progress_cb进度回调
[in]speed_cb实时速度回调
[in]transfer_cb传输信息回调
返回
HttpRequestHandle http任务句柄

◆ HttpRequest() [2/4]

nim_http::HttpRequest::HttpRequest ( const std::string &  url,
const std::string &  download_file_path,
int64_t  range_start,
const CompletedCallback complete_cb,
const ProgressCallback progress_cb = ProgressCallback(),
const SpeedCallback speed_cb = SpeedCallback(),
const TransferCallback transfer_cb = TransferCallback() 
)

NIM HTTP 创建下载文件任务,支持断点续传

参数
[in]url资源地址
[in]download_file_path下载文件保存的本地路径
[in]range_start下载文件的起始点
[in]complete_cb结束回调
[in]progress_cb进度回调
[in]speed_cb实时速度回调
[in]transfer_cb传输信息回调
返回
HttpRequestHandle http任务句柄

◆ HttpRequest() [3/4]

nim_http::HttpRequest::HttpRequest ( const std::string &  url,
const char *  post_body,
size_t  post_body_size,
const ResponseCallback response_cb,
const ProgressCallback progress_cb = ProgressCallback(),
const SpeedCallback speed_cb = SpeedCallback(),
const TransferCallback transfer_cb = TransferCallback() 
)

NIM HTTP 创建上传任务

参数
[in]url资源保存地址
[in]post_body上传的数据
[in]post_body_size上传数据的大小
[in]response_cb结束回调
[in]progress_cb进度回调
[in]speed_cb实时速度回调
[in]transfer_cb传输信息回调
返回
HttpRequestHandle http任务句柄

◆ HttpRequest() [4/4]

nim_http::HttpRequest::HttpRequest ( const std::string &  url,
const char *  post_body,
size_t  post_body_size,
const ResponseCallbackEx response_cb,
const ProgressCallback progress_cb = ProgressCallback(),
const SpeedCallback speed_cb = SpeedCallback(),
const TransferCallback transfer_cb = TransferCallback() 
)

NIM HTTP 创建上传任务

参数
[in]url资源保存地址
[in]post_body上传的数据
[in]post_body_size上传数据的大小
[in]response_cb结束回调
[in]progress_cb进度回调
[in]speed_cb实时速度回调
[in]transfer_cb传输信息回调
返回
HttpRequestHandle http任务句柄

成员函数说明

◆ AddHeader() [1/2]

void nim_http::HttpRequest::AddHeader ( const std::map< std::string, std::string > &  headers_map)

NIM HTTP 创建任务

参数
[in]headers_map头的key,头的value
返回
void 无返回值

◆ AddHeader() [2/2]

void nim_http::HttpRequest::AddHeader ( const std::string &  key,
const std::string &  value 
)

NIM HTTP 创建任务

参数
[in]key头的key
[in]value头的value
返回
void 无返回值

◆ CompletedCallbackWrapper()

void nim_http::HttpRequest::CompletedCallbackWrapper ( const void *  user_data,
bool  is_ok,
int  response_code 
)
staticprivate

◆ ProgressCallbackWrapper()

void nim_http::HttpRequest::ProgressCallbackWrapper ( const void *  user_data,
double  upload_size,
double  uploaded_size,
double  download_size,
double  downloaded_size 
)
staticprivate

◆ ResponseCallbackWrapper()

void nim_http::HttpRequest::ResponseCallbackWrapper ( const void *  user_data,
bool  is_ok,
int  response_code,
const char *  content,
const char *  head 
)
staticprivate

◆ SetLowSpeed()

void nim_http::HttpRequest::SetLowSpeed ( int  low_speed_limit,
int  low_speed_time 
)

NIM HTTP 设置最低传输速度

参数
[in]low_speed_limit最低传输的字节数(大于0)
[in]low_speed_time多少秒传输速度不得低于low_speed_limit,不满足条件则会终止传输(大于0)
返回
void 无返回值

◆ SetMethodAsPost()

void nim_http::HttpRequest::SetMethodAsPost ( )

NIM HTTP 强制设置http请求方法为post

返回
void 无返回值

◆ SetProxy()

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

NIM HTTP 设置代理

参数
[in]type代理类型NIMProxyType
[in]host代理地址
[in]port代理端口
[in]user代理账号
[in]pass代理密码
返回
void 无返回值

◆ SetTimeout()

void nim_http::HttpRequest::SetTimeout ( int  timeout_ms)

NIM HTTP 设置超时

参数
[in]timeout_ms超时时间,单位是毫秒
返回
void 无返回值

◆ SpeedCallbackWrapper()

void nim_http::HttpRequest::SpeedCallbackWrapper ( const void *  user_data,
double  upload_speed,
double  download_speed 
)
staticprivate

◆ TransferCallbackWrapper()

void nim_http::HttpRequest::TransferCallbackWrapper ( const void *  user_data,
double  actual_upload_size,
double  upload_speed,
double  actual_download_size,
double  download_speed 
)
staticprivate

友元及相关函数文档

◆ PostRequest

HttpRequestID PostRequest ( const HttpRequest http_request)
friend

类成员变量说明

◆ http_reuqest_handle_

HttpRequestHandle nim_http::HttpRequest::http_reuqest_handle_
private

该类的文档由以下文件生成: