69typedef void * http_session_t;
96 HDR_ADD_DEFAULT_USER_AGENT = 0x0001,
103 HDR_ADD_CONN_KEEP_ALIVE = 0x0002,
104 HDR_ADD_CONN_CLOSE = 0x0004,
105 HDR_ADD_TYPE_CHUNKED = 0x0008,
108 HDR_ADD_CONTENT_TYPE_JSON = 0x0010,
109 HDR_ADD_CONTENT_TYPE_FORM_URLENCODE = 0x0020,
110 HRD_ADD_DOWNLOAD_RANGE = 0x0040,
111 HRD_ADD_HTTP_RAW = 0x0080,
116#define STANDARD_HDR_FLAGS \
117 (HDR_ADD_DEFAULT_USER_AGENT)
119#define PARSE_EXTRA_BYTES 10
122typedef void (*HTTP_HEAD_ADD_CB)(http_session_t session, VOID* data);
125typedef unsigned int (*HTTP_CUSTOM_GET_CONTENT_LEN_CB)(VOID *pri_data);
126typedef int (*HTTP_CUSTOM_BEFORE_READ_CONTENT_CB)(VOID *pri_data,
unsigned int *p_malloc_buffer_size);
127typedef int (*HTTP_CUSTOM_READ_CONTENT_CB)(
unsigned char *p_buffer,
int buf_size, VOID *pri_data);
128typedef int (*HTTP_CUSTOM_AFTER_READ_CONTENT_CB)(VOID *pri_data);
131 HTTP_CUSTOM_GET_CONTENT_LEN_CB get_content_len_cb;
132 HTTP_CUSTOM_BEFORE_READ_CONTENT_CB before_read_cb;
133 HTTP_CUSTOM_READ_CONTENT_CB read_content_cb;
134 HTTP_CUSTOM_AFTER_READ_CONTENT_CB after_read_cb;
139void http_reset_session_state(http_session_t handle);
174 HTTP_HEAD_ADD_CB add_head_cb;
176 unsigned int download_offset;
177 unsigned int download_size;
280 WM_E_HTTPC_SOCKET_TIMEOUT,
283 WM_E_HTTPC_DNS_PARSE_FAILED,
285 WM_E_HTTPC_SOCKET_CREAT_FAILED,
287 WM_E_HTTPC_URL_PARSE_FAILED,
292#define HTTP_RESP_INFORMATIONAL(x) (x >=100 && < 200)
293#define HTTP_RESP_SUCCESS(x) (x >= 200 && x < 300)
294#define HTTP_RESP_REDIR(x) (x >= 300 && x < 400)
295#define HTTP_RESP_CLIENT_ERR(x) (x >= 400 && x < 500)
296#define HTTP_RESP_SERVER_ERR(x) (x >= 500 && x < 600)
303#define HTTP_CREATED 201
304#define HTTP_ACCEPTED 202
305#define HTTP_FOUND 302
306#define HTTP_NOT_MODIFIED 304
308#define HTTP_BAD_REQUEST 400
309#define HTTP_NOT_AUTH 401
310#define HTTP_FORBIDDEN 403
311#define HTTP_NOT_FOUND 404
314#define REDIRECT_CNT_MAX 5
316#define REDIRECT_CNT_DEFAULT 3
318#define REDIRECT_CNT_DISABLED 0
363 int flags,
int retry_cnt);
365int http_open_session_with_config(http_session_t *handle,
const char *hostname, \
417 const char *name,
const char *value);
525 const char *header_name,
char **value);
702int 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:95
OPERATE_RET http_redirect_limit_set(IN UINT8_T cnt)
This API is used to SET HTTP Redirect Limit Count
BOOL_T http_is_session_closed(http_session_t *handle)
int http_open_session(http_session_t *handle, const char *hostname, int flags, int retry_cnt)
wm_httpc_errno
Definition: httpc.h:255
@ WM_E_HTTPC_TCP_CONNECT_FAIL
Definition: httpc.h:264
@ WM_E_HTTPC_TCP_TLS_CONNECT_FAIL
Definition: httpc.h:266
@ WM_E_HTTPC_SOCKET_ERROR
Definition: httpc.h:275
@ WM_E_HTTPC_FILE_NOT_FOUND
Definition: httpc.h:268
@ WM_E_HTTPC_SOCKET_SHUTDOWN
Definition: httpc.h:277
@ WM_E_HTTPC_TLS_NOT_ENABLED
Definition: httpc.h:272
@ WM_E_HTTPC_BAD_REQUEST
Definition: httpc.h:270
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:325
@ TLS_ENABLE
Definition: httpc.h:327
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:167
int content_len
Definition: httpc.h:173
const char * content
Definition: httpc.h:169
const char * resource
Definition: httpc.h:163
unsigned char redirect_cnt
Definition: httpc.h:165
http_method_t type
Definition: httpc.h:159
const char * server
Definition: httpc.h:203
int keep_alive_timeout
Definition: httpc.h:222
const char * location
Definition: httpc.h:201
const char * content_type
Definition: httpc.h:209
http_ver_t version
Definition: httpc.h:190
const char * reason_phrase
Definition: httpc.h:199
int status_code
Definition: httpc.h:194
const char * protocol
Definition: httpc.h:188
bool_t keep_alive_ack
Definition: httpc.h:216
const char * content_encoding
Definition: httpc.h:211
unsigned int content_length
Definition: httpc.h:238
const char * p_accept_ranges
Definition: httpc.h:205
int keep_alive_max
Definition: httpc.h:229
bool_t chunked
Definition: httpc.h:234
time_t modify_time
Definition: httpc.h:207
Definition: tuya_tls.h:45
Common process - Initialization
tuya time service, support UTC time, local time and summer time
Common process - tls include