mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
新增mk_http_body无拷贝创建api
This commit is contained in:
parent
56586189cf
commit
5078723236
@ -145,6 +145,13 @@ typedef void* mk_http_body;
|
|||||||
*/
|
*/
|
||||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str,size_t len);
|
API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str,size_t len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成HttpBufferBody
|
||||||
|
* @param buffer mk_buffer对象
|
||||||
|
*/
|
||||||
|
API_EXPORT mk_http_body API_CALL mk_http_body_from_buffer(mk_buffer buffer);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成HttpFileBody
|
* 生成HttpFileBody
|
||||||
* @param file_path 文件完整路径
|
* @param file_path 文件完整路径
|
||||||
|
@ -253,6 +253,7 @@ API_EXPORT void API_CALL mk_media_source_for_each(void *user_data, on_mk_media_s
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////HttpBody/////////////////////////////////////////////
|
///////////////////////////////////////////HttpBody/////////////////////////////////////////////
|
||||||
|
|
||||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str, size_t len){
|
API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str, size_t len){
|
||||||
assert(str);
|
assert(str);
|
||||||
if(!len){
|
if(!len){
|
||||||
@ -261,6 +262,11 @@ API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str, size_
|
|||||||
return new HttpBody::Ptr(new HttpStringBody(std::string(str, len)));
|
return new HttpBody::Ptr(new HttpStringBody(std::string(str, len)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
API_EXPORT mk_http_body API_CALL mk_http_body_from_buffer(mk_buffer buffer) {
|
||||||
|
assert(buffer);
|
||||||
|
return new HttpBody::Ptr(new HttpBufferBody(*((Buffer::Ptr *) buffer)));
|
||||||
|
}
|
||||||
|
|
||||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_file(const char *file_path){
|
API_EXPORT mk_http_body API_CALL mk_http_body_from_file(const char *file_path){
|
||||||
assert(file_path);
|
assert(file_path);
|
||||||
return new HttpBody::Ptr(new HttpFileBody(file_path));
|
return new HttpBody::Ptr(new HttpFileBody(file_path));
|
||||||
|
@ -16,7 +16,7 @@ typedef struct {
|
|||||||
mk_http_requester requester;
|
mk_http_requester requester;
|
||||||
} Context;
|
} Context;
|
||||||
|
|
||||||
void API_CALL on_requester_complete(void *user_data, int code, const char *err_msg){
|
static void API_CALL on_requester_complete(void *user_data, int code, const char *err_msg){
|
||||||
Context *ctx = (Context *)user_data;
|
Context *ctx = (Context *)user_data;
|
||||||
log_debug("code: %d %s", code, err_msg);
|
log_debug("code: %d %s", code, err_msg);
|
||||||
size_t res_len = 0;
|
size_t res_len = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user