68typedef void * http_session_t;
95 HDR_ADD_DEFAULT_USER_AGENT = 0x0001,
102 HDR_ADD_CONN_KEEP_ALIVE = 0x0002,
103 HDR_ADD_CONN_CLOSE = 0x0004,
104 HDR_ADD_TYPE_CHUNKED = 0x0008,
107 HDR_ADD_CONTENT_TYPE_JSON = 0x0010,
108 HDR_ADD_CONTENT_TYPE_FORM_URLENCODE = 0x0020,
109 HRD_ADD_DOWNLOAD_RANGE = 0x0040,
110 HRD_ADD_HTTP_RAW = 0x0080,
115#define STANDARD_HDR_FLAGS \
116 (HDR_ADD_DEFAULT_USER_AGENT)
119typedef void (*HTTP_HEAD_ADD_CB)(http_session_t session, VOID* data);
122typedef unsigned int (*HTTP_CUSTOM_GET_CONTENT_LEN_CB)(VOID *pri_data);
123typedef int (*HTTP_CUSTOM_BEFORE_READ_CONTENT_CB)(VOID *pri_data,
unsigned int *p_malloc_buffer_size);
124typedef int (*HTTP_CUSTOM_READ_CONTENT_CB)(
unsigned char *p_buffer,
int buf_size, VOID *pri_data);
125typedef int (*HTTP_CUSTOM_AFTER_READ_CONTENT_CB)(VOID *pri_data);
128 HTTP_CUSTOM_GET_CONTENT_LEN_CB get_content_len_cb;
129 HTTP_CUSTOM_BEFORE_READ_CONTENT_CB before_read_cb;
130 HTTP_CUSTOM_READ_CONTENT_CB read_content_cb;
131 HTTP_CUSTOM_AFTER_READ_CONTENT_CB after_read_cb;
136void http_reset_session_state(http_session_t handle);
171 HTTP_HEAD_ADD_CB add_head_cb;
173 unsigned int download_offset;
174 unsigned int download_size;
245 const char *hostname;
247 const char *resource;
277 WM_E_HTTPC_SOCKET_TIMEOUT,
280 WM_E_HTTPC_DNS_PARSE_FAILED,
282 WM_E_HTTPC_SOCKET_CREAT_FAILED,
284 WM_E_HTTPC_URL_PARSE_FAILED,
289#define HTTP_RESP_INFORMATIONAL(x) (x >=100 && < 200)
290#define HTTP_RESP_SUCCESS(x) (x >= 200 && x < 300)
291#define HTTP_RESP_REDIR(x) (x >= 300 && x < 400)
292#define HTTP_RESP_CLIENT_ERR(x) (x >= 400 && x < 500)
293#define HTTP_RESP_SERVER_ERR(x) (x >= 500 && x < 600)
300#define HTTP_CREATED 201
301#define HTTP_ACCEPTED 202
302#define HTTP_FOUND 302
303#define HTTP_NOT_MODIFIED 304
305#define HTTP_BAD_REQUEST 400
306#define HTTP_NOT_AUTH 401
307#define HTTP_FORBIDDEN 403
308#define HTTP_NOT_FOUND 404
311#define REDIRECT_CNT_MAX 5
313#define REDIRECT_CNT_DEFAULT 3
315#define REDIRECT_CNT_DISABLED 0
360 int flags,
int retry_cnt);
411 const char *name,
const char *value);
519 const char *header_name,
char **value);
696int http_write_standard(http_session_t handle,
const void *buf,
unsigned len);
int http_get_response_hdr_all(http_session_t handle, http_header_pair_t *arr, int *count)
OPERATE_RET http_recv_timeout_set(IN UINT8_T timeout_s)
This API is used to SET HTTP recv timeout
int http_read_content(http_session_t handle, void *buf, unsigned int max_len)
UINT8_T http_recv_timeout_get(void)
This API is used to GET HTTP recv timeout
int http_get_response_hdr(http_session_t handle, http_resp_t **resp)
void http_close_session(http_session_t *handle)
int http_send_request(http_session_t handle, const http_req_t *req, int send_content)
int http_lowlevel_write(http_session_t handle, const void *buf, unsigned len)
UINT8_T http_redirect_limit_get(void)
This API is used to GET HTTP Redirect Limit Count
http_hdr_field_sel_t
Definition: httpc.h:94
OPERATE_RET http_redirect_limit_set(IN UINT8_T cnt)
This API is used to SET HTTP Redirect Limit Count
int http_open_session(http_session_t *handle, const char *hostname, int flags, int retry_cnt)
wm_httpc_errno
Definition: httpc.h:252
@ WM_E_HTTPC_TCP_CONNECT_FAIL
Definition: httpc.h:261
@ WM_E_HTTPC_TCP_TLS_CONNECT_FAIL
Definition: httpc.h:263
@ WM_E_HTTPC_SOCKET_ERROR
Definition: httpc.h:272
@ WM_E_HTTPC_FILE_NOT_FOUND
Definition: httpc.h:265
@ WM_E_HTTPC_SOCKET_SHUTDOWN
Definition: httpc.h:274
@ WM_E_HTTPC_TLS_NOT_ENABLED
Definition: httpc.h:269
@ WM_E_HTTPC_BAD_REQUEST
Definition: httpc.h:267
int http_add_header(http_session_t handle, const http_req_t *req, const char *name, const char *value)
int http_get_response_hdr_value(http_session_t handle, const char *header_name, char **value)
http_open_flags_t
Definition: httpc.h:322
@ TLS_ENABLE
Definition: httpc.h:324
int http_parse_URL(const char *URL, char *tmp_buf, int tmp_buf_len, parsed_url_t *parsed_url)
int http_lowlevel_read(http_session_t handle, void *buf, unsigned maxlen)
int http_prepare_req(http_session_t handle, const http_req_t *req, http_hdr_field_sel_t field_flags)
int httpc_write_chunked(http_session_t handle, const char *data, int len)
http_ver_t version
Definition: httpc.h:164
int content_len
Definition: httpc.h:170
const char * content
Definition: httpc.h:166
const char * resource
Definition: httpc.h:160
unsigned char redirect_cnt
Definition: httpc.h:162
http_method_t type
Definition: httpc.h:156
const char * server
Definition: httpc.h:200
int keep_alive_timeout
Definition: httpc.h:219
const char * location
Definition: httpc.h:198
const char * content_type
Definition: httpc.h:206
http_ver_t version
Definition: httpc.h:187
const char * reason_phrase
Definition: httpc.h:196
int status_code
Definition: httpc.h:191
const char * protocol
Definition: httpc.h:185
bool_t keep_alive_ack
Definition: httpc.h:213
const char * content_encoding
Definition: httpc.h:208
unsigned int content_length
Definition: httpc.h:235
const char * p_accept_ranges
Definition: httpc.h:202
int keep_alive_max
Definition: httpc.h:226
bool_t chunked
Definition: httpc.h:231
time_t modify_time
Definition: httpc.h:204
tuya time service, support UTC time, local time and summer time
Common process - Initialization