TuyaOS
|
Wrapper of HTTP request and response 更多...
结构体 | |
struct | HTTP_URL_H_S |
Definition of HTTP URL structure 更多... | |
宏定义 | |
#define | DEF_URL_LEN 1024 |
#define | http_inf_client_get(url, callback, pri_data) http_inf_client_get_with_head(url, callback, pri_data, NULL, NULL) |
This API is used to GET HTTP request/response 更多... | |
#define | http_inf_client_get_file(url, callback, pri_data, file_offset, file_size) http_inf_client_get_file_session(url, callback, pri_data, file_offset, file_size, FALSE) |
This API is used to GET HTTP file 更多... | |
#define | http_inf_client_get_raw(url, p_inf, offset, total_len) http_inf_client_get_raw_with_head(url, p_inf, offset, total_len, NULL, NULL) |
This API is used to GET raw HTTP request/response 更多... | |
#define | http_inf_client_post(url, callback, data, len, add_head_cb, add_head_data, p_decode_key, pri_data) |
#define | http_inf_client_post_field(url, callback, data, len, add_head_cb, add_head_data, p_decode_key, pri_data, field_flags) |
#define | http_inf_client_post_raw(url, len, p_inf) |
#define | http_inf_client_post_session(url, callback, data, len, add_head_cb, add_head_data, p_decode_key, pri_data, session_persistence) |
#define | http_inf_client_put_raw(url, len, p_inf) http_inf_client_put_raw_field(url, len, p_inf, NULL, NULL) |
This API is used to PUT raw HTTP request/response 更多... | |
类型定义 | |
typedef INT_T(* | HTTP_DATA_RECV) (PVOID_T hand, PVOID_T buf, UINT_T len) |
This API is used to handle HTTP response content 更多... | |
typedef OPERATE_RET(* | HTTP_INF_CB) (HTTP_INF_H_S *hand) |
This API is used to handle customized HTTP response 更多... | |
函数 | |
HTTP_URL_H_S * | create_http_url_h (IN CONST USHORT_T buf_len, IN CONST USHORT_T param_cnt) |
Create url of HTTP request 更多... | |
VOID | del_http_url_h (IN HTTP_URL_H_S *hu_h) |
Free url of HTTP request 更多... | |
OPERATE_RET | fill_url_head (INOUT HTTP_URL_H_S *hu_h, IN CONST CHAR_T *url_h) |
Initiaze url of HTTP request 更多... | |
OPERATE_RET | fill_url_param (INOUT HTTP_URL_H_S *hu_h, IN CONST CHAR_T *key, IN CONST CHAR_T *value) |
Add key/value param to HTTP url 更多... | |
OPERATE_RET | http_inf_client_add_head_cb_post (IN CONST char *url, IN CONST HTTP_INF_CB callback, IN CONST BYTE_T *data, IN CONST UINT_T len, IN HTTP_HEAD_ADD_CB add_head_cb, IN VOID *add_head_data, INOUT PVOID_T *pri_data) |
This API is used to POST HTTP request/response 更多... | |
OPERATE_RET | http_inf_client_get_file_session (IN CONST CHAR_T *url, IN CONST HTTP_INF_CB callback, INOUT PVOID_T *pri_data, IN CONST UINT_T file_offset, IN CONST UINT_T file_size, IN BOOL_T session_persistence) |
This API is used to GET HTTP file 更多... | |
OPERATE_RET | http_inf_client_get_raw_with_head (IN CONST CHAR_T *url, INOUT HTTP_INF_H_S *p_inf, IN UINT_T offset, IN UINT_T total_len, IN HTTP_HEAD_ADD_CB add_head_cb, IN VOID *add_head_data) |
This API is used to GET raw HTTP request/response 更多... | |
OPERATE_RET | http_inf_client_get_with_head (IN CONST CHAR_T *url, IN CONST HTTP_INF_CB callback, INOUT PVOID_T *pri_data, IN HTTP_HEAD_ADD_CB add_head_cb, IN VOID *add_head_data) |
This API is used to GET HTTP request/response 更多... | |
OPERATE_RET | http_inf_client_post_field_session (IN CONST CHAR_T *url, IN CONST HTTP_INF_CB callback, IN CONST BYTE_T *data, IN CONST UINT_T len, IN HTTP_HEAD_ADD_CB add_head_cb, IN VOID *add_head_data, IN CONST CHAR_T *p_decode_key, INOUT PVOID_T *pri_data, IN CONST http_hdr_field_sel_t field_flags, IN BOOL_T session_persistence) |
This API is used to POST HTTP request/response 更多... | |
OPERATE_RET | http_inf_client_post_raw_field (IN CONST CHAR_T *url, IN CONST UINT_T len, INOUT HTTP_INF_H_S *p_inf, IN http_hdr_field_sel_t field_flags) |
This API is used to POST raw HTTP request/response 更多... | |
OPERATE_RET | http_inf_client_put (IN CONST CHAR_T *url, IN CONST HTTP_INF_CB callback, IN CONST BYTE_T *data, IN CONST UINT_T len, IN HTTP_HEAD_ADD_CB add_head_cb, IN VOID *add_head_data, INOUT PVOID_T *pri_data) |
This API is used to PUT HTTP request/response 更多... | |
OPERATE_RET | http_inf_client_put_custom_content (IN CONST CHAR_T *url, IN CONST HTTP_INF_CB callback, IN http_custom_content_ctx_s *p_ctx, IN HTTP_HEAD_ADD_CB add_head_cb, IN VOID *add_head_data, INOUT PVOID_T *pri_data) |
This API is used to PUT HTTP request/response with customized content 更多... | |
OPERATE_RET | http_inf_client_put_raw_field (IN CONST CHAR_T *url, IN INT_T len, INOUT HTTP_INF_H_S *p_inf, IN HTTP_HEAD_ADD_CB add_head_cb, IN VOID *add_head_data) |
This API is used to PUT raw HTTP request/response, extra header is supported 更多... | |
OPERATE_RET | http_inf_client_set_session_timeout (IN UINT16_T timeout_ms) |
This API is used to set the global default session timeout 更多... | |
OPERATE_RET | http_inf_close_raw (INOUT HTTP_INF_H_S *p_inf) |
This API is used to close raw HTTP request 更多... | |
OPERATE_RET | http_inf_com_hanle_with_tls_config (IN CONST http_req_t *req, IN CONST CHAR_T *url, IN CONST tuya_tls_config_t *tls_config, IN CONST http_hdr_field_sel_t field_flags, IN CONST HTTP_INF_CB callback, IN CONST CHAR_T *p_decode_key, INOUT PVOID_T *pri_data) |
INT_T | http_inf_write_content_raw (INOUT HTTP_INF_H_S *p_inf, IN CONST BYTE_T *p_data, IN CONST UINT_T len, BOOL_T chunked) |
This API is used to write raw HTTP request content 更多... | |
INT_T | httpc_inf_read_content_raw (IN HTTP_INF_H_S *p_inf, IN BYTE_T *buf, IN CONST UINT_T buf_len) |
This API is used to read raw HTTP response content 更多... | |
OPERATE_RET | httpc_inf_read_header_raw (INOUT HTTP_INF_H_S *p_inf) |
This API is used to read raw HTTP response header 更多... | |
Wrapper of HTTP request and response
#define http_inf_client_get | ( | url, | |
callback, | |||
pri_data | |||
) | http_inf_client_get_with_head(url, callback, pri_data, NULL, NULL) |
This API is used to GET HTTP request/response
[in] | url | URL of HTTP request |
[in] | callback | Handler of HTTP response |
[in] | pri_data | Private data used by HTTP request |
#define http_inf_client_get_file | ( | url, | |
callback, | |||
pri_data, | |||
file_offset, | |||
file_size | |||
) | http_inf_client_get_file_session(url, callback, pri_data, file_offset, file_size, FALSE) |
This API is used to GET HTTP file
[in] | url | URL of HTTP request |
[in] | callback | Handler of HTTP response |
[in] | pri_data | Private data used by HTTP request |
[in] | file_offset | Offset of file content |
[in] | file_size | Max size to get from file |
#define http_inf_client_get_raw | ( | url, | |
p_inf, | |||
offset, | |||
total_len | |||
) | http_inf_client_get_raw_with_head(url, p_inf, offset, total_len, NULL, NULL) |
This API is used to GET raw HTTP request/response
[in] | url | URL of HTTP request |
[in] | p_inf | Pointer to HTTP_INF_H_S |
[in] | offset | Offset of file content |
[in] | total_len | Max size to get from file |
#define http_inf_client_post | ( | url, | |
callback, | |||
data, | |||
len, | |||
add_head_cb, | |||
add_head_data, | |||
p_decode_key, | |||
pri_data | |||
) |
#define http_inf_client_post_field | ( | url, | |
callback, | |||
data, | |||
len, | |||
add_head_cb, | |||
add_head_data, | |||
p_decode_key, | |||
pri_data, | |||
field_flags | |||
) |
#define http_inf_client_post_raw | ( | url, | |
len, | |||
p_inf | |||
) |
#define http_inf_client_post_session | ( | url, | |
callback, | |||
data, | |||
len, | |||
add_head_cb, | |||
add_head_data, | |||
p_decode_key, | |||
pri_data, | |||
session_persistence | |||
) |
#define http_inf_client_put_raw | ( | url, | |
len, | |||
p_inf | |||
) | http_inf_client_put_raw_field(url, len, p_inf, NULL, NULL) |
This API is used to PUT raw HTTP request/response
[in] | url | URL of HTTP request |
[in] | len | Max length of HTTP response data |
[in] | p_inf | Pointer to HTTP_INF_H_S |
typedef INT_T(* HTTP_DATA_RECV) (PVOID_T hand, PVOID_T buf, UINT_T len) |
This API is used to handle HTTP response content
[in] | hand | http_session_t |
[in] | buf | Buffer of HTTP response content |
[in] | len | length of buf |
typedef OPERATE_RET(* HTTP_INF_CB) (HTTP_INF_H_S *hand) |
This API is used to handle customized HTTP response
[in] | hand | Pointer to HTTP_INF_H_S |
HTTP_URL_H_S * create_http_url_h | ( | IN CONST USHORT_T | buf_len, |
IN CONST USHORT_T | param_cnt | ||
) |
Create url of HTTP request
[in] | buf_len | max lenth of URL(include params) |
[in] | param_cnt | max count of url params |
VOID del_http_url_h | ( | IN HTTP_URL_H_S * | hu_h | ) |
Free url of HTTP request
[in] | hu_h | A pointer that points to the structure returned from the call to create_http_url_h |
OPERATE_RET fill_url_head | ( | INOUT HTTP_URL_H_S * | hu_h, |
IN CONST CHAR_T * | url_h | ||
) |
Initiaze url of HTTP request
[in,out] | hu_h | A pointer that points to the structure returned from the call to create_http_url_h |
[in] | url_h | HTTP url |
OPERATE_RET fill_url_param | ( | INOUT HTTP_URL_H_S * | hu_h, |
IN CONST CHAR_T * | key, | ||
IN CONST CHAR_T * | value | ||
) |
Add key/value param to HTTP url
[in,out] | hu_h | A pointer that points to the structure returned from the call to create_http_url_h |
[in] | key | Key to be added to url |
[in] | value | Value to be added to url |
OPERATE_RET http_inf_client_add_head_cb_post | ( | IN CONST char * | url, |
IN CONST HTTP_INF_CB | callback, | ||
IN CONST BYTE_T * | data, | ||
IN CONST UINT_T | len, | ||
IN HTTP_HEAD_ADD_CB | add_head_cb, | ||
IN VOID * | add_head_data, | ||
INOUT PVOID_T * | pri_data | ||
) |
This API is used to POST HTTP request/response
[in] | url | URL of HTTP request |
[in] | callback | Handler of HTTP response |
[in] | data | data of HTTP request |
[in] | len | length of HTTP request data |
[in] | add_head_cb | Hook before HTTP request sent, to add more HTTP header |
[in] | add_head_data | Header data of add_head_cb |
[in] | pri_data | Private data used by HTTP request |
OPERATE_RET http_inf_client_get_file_session | ( | IN CONST CHAR_T * | url, |
IN CONST HTTP_INF_CB | callback, | ||
INOUT PVOID_T * | pri_data, | ||
IN CONST UINT_T | file_offset, | ||
IN CONST UINT_T | file_size, | ||
IN BOOL_T | session_persistence | ||
) |
This API is used to GET HTTP file
[in] | url | URL of HTTP request |
[in] | callback | Handler of HTTP response |
[in] | pri_data | Private data used by HTTP request |
[in] | file_offset | Offset of file content |
[in] | file_size | Max size to get from file |
[in] | session_persistence | auto handle session persistence with the same host and port |
OPERATE_RET http_inf_client_get_raw_with_head | ( | IN CONST CHAR_T * | url, |
INOUT HTTP_INF_H_S * | p_inf, | ||
IN UINT_T | offset, | ||
IN UINT_T | total_len, | ||
IN HTTP_HEAD_ADD_CB | add_head_cb, | ||
IN VOID * | add_head_data | ||
) |
This API is used to GET raw HTTP request/response
[in] | url | URL of HTTP request |
[in] | p_inf | Pointer to HTTP_INF_H_S |
[in] | offset | Offset of file content |
[in] | total_len | Max size to get from file |
[in] | add_head_cb | Hook before HTTP request sent, to add more HTTP header |
[in] | add_head_data | Header data of add_head_cb |
OPERATE_RET http_inf_client_get_with_head | ( | IN CONST CHAR_T * | url, |
IN CONST HTTP_INF_CB | callback, | ||
INOUT PVOID_T * | pri_data, | ||
IN HTTP_HEAD_ADD_CB | add_head_cb, | ||
IN VOID * | add_head_data | ||
) |
This API is used to GET HTTP request/response
[in] | url | URL of HTTP request |
[in] | callback | Handler of HTTP response |
[in] | pri_data | Private data used by HTTP request |
[in] | add_head_cb | Hook before HTTP request sent, to add more HTTP header |
[in] | add_head_data | Header data of add_head_cb |
OPERATE_RET http_inf_client_post_field_session | ( | IN CONST CHAR_T * | url, |
IN CONST HTTP_INF_CB | callback, | ||
IN CONST BYTE_T * | data, | ||
IN CONST UINT_T | len, | ||
IN HTTP_HEAD_ADD_CB | add_head_cb, | ||
IN VOID * | add_head_data, | ||
IN CONST CHAR_T * | p_decode_key, | ||
INOUT PVOID_T * | pri_data, | ||
IN CONST http_hdr_field_sel_t | field_flags, | ||
IN BOOL_T | session_persistence | ||
) |
This API is used to POST HTTP request/response
[in] | url | URL of HTTP request |
[in] | callback | Handler of HTTP response |
[in] | data | data of HTTP request |
[in] | len | length of HTTP request data |
[in] | add_head_cb | Hook before HTTP request sent, to add more HTTP header |
[in] | add_head_data | Header data of add_head_cb |
[in] | p_decode_key | Decode key of HTTP content |
[in] | pri_data | Private data used by HTTP request |
[in] | field_flags | The http_hdr_field_sel_t, OR of zero or more flags |
[in] | session_persistence | Indicate session persistence support |
OPERATE_RET http_inf_client_post_raw_field | ( | IN CONST CHAR_T * | url, |
IN CONST UINT_T | len, | ||
INOUT HTTP_INF_H_S * | p_inf, | ||
IN http_hdr_field_sel_t | field_flags | ||
) |
This API is used to POST raw HTTP request/response
[in] | url | URL of HTTP request |
[in] | len | Max length of HTTP response data |
[in] | p_inf | Pointer to HTTP_INF_H_S |
[in] | field_flags | The http_hdr_field_sel_t, OR of zero or more flags |
OPERATE_RET http_inf_client_put | ( | IN CONST CHAR_T * | url, |
IN CONST HTTP_INF_CB | callback, | ||
IN CONST BYTE_T * | data, | ||
IN CONST UINT_T | len, | ||
IN HTTP_HEAD_ADD_CB | add_head_cb, | ||
IN VOID * | add_head_data, | ||
INOUT PVOID_T * | pri_data | ||
) |
This API is used to PUT HTTP request/response
[in] | url | URL of HTTP request |
[in] | callback | Handler of HTTP response |
[in] | data | data of HTTP request |
[in] | len | length of HTTP request data |
[in] | add_head_cb | Hook before HTTP request sent, to add more HTTP header |
[in] | add_head_data | Header data of add_head_cb |
[in] | pri_data | Private data used by HTTP request |
OPERATE_RET http_inf_client_put_custom_content | ( | IN CONST CHAR_T * | url, |
IN CONST HTTP_INF_CB | callback, | ||
IN http_custom_content_ctx_s * | p_ctx, | ||
IN HTTP_HEAD_ADD_CB | add_head_cb, | ||
IN VOID * | add_head_data, | ||
INOUT PVOID_T * | pri_data | ||
) |
This API is used to PUT HTTP request/response with customized content
[in] | url | URL of HTTP request |
[in] | callback | Handler of HTTP response |
[in] | p_ctx | Context of HTTP request customized |
[in] | add_head_cb | Hook before HTTP request sent, to add more HTTP header |
[in] | add_head_data | Header data of add_head_cb |
[in] | pri_data | Private data used by HTTP request |
OPERATE_RET http_inf_client_put_raw_field | ( | IN CONST CHAR_T * | url, |
IN INT_T | len, | ||
INOUT HTTP_INF_H_S * | p_inf, | ||
IN HTTP_HEAD_ADD_CB | add_head_cb, | ||
IN VOID * | add_head_data | ||
) |
This API is used to PUT raw HTTP request/response, extra header is supported
[in] | url | URL of HTTP request |
[in] | len | Max length of HTTP response data |
[in] | p_inf | Pointer to HTTP_INF_H_S |
[in] | add_head_cb | Hook before HTTP request sent, to add more HTTP header |
[in] | add_head_data | Header data of add_head_cb |
OPERATE_RET http_inf_client_set_session_timeout | ( | IN UINT16_T | timeout_ms | ) |
This API is used to set the global default session timeout
[in] | timeout_ms | session timeout in millisecond |
OPERATE_RET http_inf_close_raw | ( | INOUT HTTP_INF_H_S * | p_inf | ) |
This API is used to close raw HTTP request
[in] | p_inf | Pointer to HTTP_INF_H_S |
OPERATE_RET http_inf_com_hanle_with_tls_config | ( | IN CONST http_req_t * | req, |
IN CONST CHAR_T * | url, | ||
IN CONST tuya_tls_config_t * | tls_config, | ||
IN CONST http_hdr_field_sel_t | field_flags, | ||
IN CONST HTTP_INF_CB | callback, | ||
IN CONST CHAR_T * | p_decode_key, | ||
INOUT PVOID_T * | pri_data | ||
) |
[in/out] | req |
[in/out] | url |
[in/out] | tls_config |
[in/out] | field_flags |
[in/out] | callback |
[in/out] | p_decode_key |
[in/out] | pri_data |
INT_T http_inf_write_content_raw | ( | INOUT HTTP_INF_H_S * | p_inf, |
IN CONST BYTE_T * | p_data, | ||
IN CONST UINT_T | len, | ||
BOOL_T | chunked | ||
) |
This API is used to write raw HTTP request content
[in] | p_inf | Pointer to HTTP_INF_H_S |
[in] | p_data | Buffer to write of HTTP request |
[in] | buf_len | Max length of HTTP request data |
[in] | chunked | Chunk is enabled or not |
INT_T httpc_inf_read_content_raw | ( | IN HTTP_INF_H_S * | p_inf, |
IN BYTE_T * | buf, | ||
IN CONST UINT_T | buf_len | ||
) |
This API is used to read raw HTTP response content
[in] | p_inf | Pointer to HTTP_INF_H_S |
[in] | buf | Buffer to read HTTP response |
[in] | buf_len | Max length of HTTP response data |
OPERATE_RET httpc_inf_read_header_raw | ( | INOUT HTTP_INF_H_S * | p_inf | ) |
This API is used to read raw HTTP response header
[in,out] | p_inf | Pointer to HTTP_INF_H_S |