Files
2026-08-13 16:50:52 +08:00

46 lines
936 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// httpclient.h
#ifndef LINGXIN_HTTP_HTTPCLIENT_H
#define LINGXIN_HTTP_HTTPCLIENT_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <stddef.h>
typedef void (*RequestCallback)(void *contents, size_t size, void *userp);
typedef struct
{
const char *signature;
const char *sn;
const char *app_id;
const char *timestamp;
} HttpHeader;
typedef struct
{
const char *protocol; // http or https
const char *host;
const char *path;
int port;
const char *post_data;
HttpHeader *headers;
} HttpConfig;
/**
* http_post 方法适配
*
* @param config http配置
* @param userCallback 回调函数
* @param userData 需要透传的参数在userCallback中会透传给用户
*
* @return: 0: fail 其他: success
*/
int http_post(HttpConfig *config, RequestCallback userCallback, void *userData);
#ifdef __cplusplus
}
#endif
#endif // LINGXIN_HTTP_HTTPCLIENT_H