8#if defined(AIR101) || defined(AIR103)
10#define HTTP_RESP_BUFF_SIZE (2048)
13#define HTTP_RESP_BUFF_SIZE (8192)
16#include "http_parser.h"
17#define HTTP_HEADER_BASE_SIZE (1024)
18#define HTTP_RESP_BUFF_SIZE (4096)
47typedef void (*
luat_http_cb)(
int status,
void *data, uint32_t data_len,
void *user_param);
49#define HTTP_GET_DATA (2)
50#define HTTP_POST_DATA (1)
54#define HTTP_ERROR_STATE (-1)
55#define HTTP_ERROR_HEADER (-2)
56#define HTTP_ERROR_BODY (-3)
57#define HTTP_ERROR_CONNECT (-4)
58#define HTTP_ERROR_CLOSE (-5)
59#define HTTP_ERROR_RX (-6)
60#define HTTP_ERROR_DOWNLOAD (-7)
61#define HTTP_ERROR_TIMEOUT (-8)
62#define HTTP_ERROR_FOTA (-9)
64#define HTTP_CALLBACK (1)
66#define HTTP_RE_REQUEST_MAX (3)
68#define HTTP_TIMEOUT (10*60*1000)
83 luat_ip_addr_t ip_addr;
93 luat_zbuff_t *zbuff_body;
103 int http_cb_userdata;
110 uint32_t headers_len;
114 uint8_t re_request_count;
116 int32_t resp_content_len;
120 uint8_t headers_complete;
123 size_t resp_buff_offset;
124 size_t resp_headers_done;
184 const char *client_cert, uint32_t client_cert_len,
185 const char *client_cert_key, uint32_t client_cert_key_len,
186 const char *client_cert_key_password, uint32_t client_cert_key_password_len);
int luat_http_client_base_config(luat_http_ctrl_t *http_ctrl, uint32_t timeout, uint8_t debug_onoff, uint8_t retry_cnt)
http客户端的通用配置,创建客户端时已经有默认配置,可以不配置
int luat_http_client_set_get_offset(luat_http_ctrl_t *http_ctrl, uint32_t offset)
GET请求时要求服务器从offset位置开始传输数据,谨慎使用
int luat_http_client_get_status_code(luat_http_ctrl_t *http_ctrl)
http获取状态码
int luat_http_client_pause(luat_http_ctrl_t *http_ctrl, uint8_t is_pause)
http客户端设置暂停
int luat_http_client_start(luat_http_ctrl_t *http_ctrl, const char *url, uint8_t type, uint8_t ipv6, uint8_t continue_mode)
启动一个http请求
int luat_http_client_destroy(luat_http_ctrl_t **p_http_ctrl)
完全释放掉当前的http客户端
int luat_http_client_ssl_config(luat_http_ctrl_t *http_ctrl, int mode, const char *server_cert, uint32_t server_cert_len, const char *client_cert, uint32_t client_cert_len, const char *client_cert_key, uint32_t client_cert_key_len, const char *client_cert_key_password, uint32_t client_cert_key_password_len)
客户端SSL配置,只有访问https才需要配置
luat_http_ctrl_t * luat_http_client_create(luat_http_cb cb, void *user_param, int adapter_index)
创建一个http客户端
int luat_http_client_post_body(luat_http_ctrl_t *http_ctrl, void *data, uint32_t len)
POST请求时发送body数据,如果数据量比较大,可以在HTTP_STATE_SEND_BODY回调里分次发送
int luat_http_client_close(luat_http_ctrl_t *http_ctrl)
停止当前的http请求,调用后不再有http回调了
void(* luat_http_cb)(int status, void *data, uint32_t data_len, void *user_param)
int luat_http_client_set_user_head(luat_http_ctrl_t *http_ctrl, const char *name, const char *value)
设置一条用户的request head参数,Content-Length一般不需要,在设置POST的body时自动生成
int luat_http_client_clear(luat_http_ctrl_t *http_ctrl)
清空用户设置的POST数据和request head参数
@ HTTP_STATE_SEND_BODY_START
#define HTTP_RESP_BUFF_SIZE
Buffer_Struct response_cache
Buffer_Struct response_head_buffer
Buffer_Struct request_head_buffer