TuyaOS
结构体 | 宏定义 | 类型定义 | 函数
http_inf.h 文件参考

Wrapper of HTTP request and response 更多...

#include "tuya_cloud_types.h"
#include "httpc.h"
#include "log_seq.h"
http_inf.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

结构体

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_Screate_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

版本
0.1
日期
2016-10-28

宏定义说明

◆ http_inf_client_get

#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]urlURL of HTTP request
[in]callbackHandler of HTTP response
[in]pri_dataPrivate data used by HTTP request
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_get_file

#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]urlURL of HTTP request
[in]callbackHandler of HTTP response
[in]pri_dataPrivate data used by HTTP request
[in]file_offsetOffset of file content
[in]file_sizeMax size to get from file
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_get_raw

#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]urlURL of HTTP request
[in]p_infPointer to HTTP_INF_H_S
[in]offsetOffset of file content
[in]total_lenMax size to get from file
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_post

#define http_inf_client_post (   url,
  callback,
  data,
  len,
  add_head_cb,
  add_head_data,
  p_decode_key,
  pri_data 
)
值:
http_inf_client_post_field(url, callback, data, len, add_head_cb, add_head_data, p_decode_key, pri_data, \
STANDARD_HDR_FLAGS|HDR_ADD_CONN_KEEP_ALIVE|HDR_ADD_CONTENT_TYPE_FORM_URLENCODE)

◆ http_inf_client_post_field

#define http_inf_client_post_field (   url,
  callback,
  data,
  len,
  add_head_cb,
  add_head_data,
  p_decode_key,
  pri_data,
  field_flags 
)
值:
http_inf_client_post_field_session(url, callback, data, len, \
add_head_cb, add_head_data, \
p_decode_key, pri_data, field_flags, FALSE)
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

◆ http_inf_client_post_raw

#define http_inf_client_post_raw (   url,
  len,
  p_inf 
)
值:
http_inf_client_post_raw_field(url, len, p_inf, \
HRD_ADD_HTTP_RAW | STANDARD_HDR_FLAGS | HDR_ADD_CONN_KEEP_ALIVE | HDR_ADD_CONTENT_TYPE_JSON)
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

◆ http_inf_client_post_session

#define http_inf_client_post_session (   url,
  callback,
  data,
  len,
  add_head_cb,
  add_head_data,
  p_decode_key,
  pri_data,
  session_persistence 
)
值:
http_inf_client_post_field_session(url, callback, data, len, \
add_head_cb, add_head_data, \
p_decode_key, pri_data, \
STANDARD_HDR_FLAGS|HDR_ADD_CONN_KEEP_ALIVE|HDR_ADD_CONTENT_TYPE_FORM_URLENCODE, \
session_persistence)

◆ http_inf_client_put_raw

#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]urlURL of HTTP request
[in]lenMax length of HTTP response data
[in]p_infPointer to HTTP_INF_H_S
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

类型定义说明

◆ HTTP_DATA_RECV

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]handhttp_session_t
[in]bufBuffer of HTTP response content
[in]lenlength of buf
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ HTTP_INF_CB

typedef OPERATE_RET(* HTTP_INF_CB) (HTTP_INF_H_S *hand)

This API is used to handle customized HTTP response

参数
[in]handPointer to HTTP_INF_H_S
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

函数说明

◆ create_http_url_h()

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_lenmax lenth of URL(include params)
[in]param_cntmax count of url params
返回
NULL on error. Pointer to HTTP_URL_H_S on success

◆ del_http_url_h()

VOID del_http_url_h ( IN HTTP_URL_H_S hu_h)

Free url of HTTP request

参数
[in]hu_hA pointer that points to the structure returned from the call to create_http_url_h

◆ fill_url_head()

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_hA pointer that points to the structure returned from the call to create_http_url_h
[in]url_hHTTP url
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ fill_url_param()

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_hA pointer that points to the structure returned from the call to create_http_url_h
[in]keyKey to be added to url
[in]valueValue to be added to url
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_add_head_cb_post()

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]urlURL of HTTP request
[in]callbackHandler of HTTP response
[in]datadata of HTTP request
[in]lenlength of HTTP request data
[in]add_head_cbHook before HTTP request sent, to add more HTTP header
[in]add_head_dataHeader data of add_head_cb
[in]pri_dataPrivate data used by HTTP request
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_get_file_session()

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]urlURL of HTTP request
[in]callbackHandler of HTTP response
[in]pri_dataPrivate data used by HTTP request
[in]file_offsetOffset of file content
[in]file_sizeMax size to get from file
[in]session_persistenceauto handle session persistence with the same host and port
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_get_raw_with_head()

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]urlURL of HTTP request
[in]p_infPointer to HTTP_INF_H_S
[in]offsetOffset of file content
[in]total_lenMax size to get from file
[in]add_head_cbHook before HTTP request sent, to add more HTTP header
[in]add_head_dataHeader data of add_head_cb
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_get_with_head()

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]urlURL of HTTP request
[in]callbackHandler of HTTP response
[in]pri_dataPrivate data used by HTTP request
[in]add_head_cbHook before HTTP request sent, to add more HTTP header
[in]add_head_dataHeader data of add_head_cb
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_post_field_session()

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]urlURL of HTTP request
[in]callbackHandler of HTTP response
[in]datadata of HTTP request
[in]lenlength of HTTP request data
[in]add_head_cbHook before HTTP request sent, to add more HTTP header
[in]add_head_dataHeader data of add_head_cb
[in]p_decode_keyDecode key of HTTP content
[in]pri_dataPrivate data used by HTTP request
[in]field_flagsThe http_hdr_field_sel_t, OR of zero or more flags
[in]session_persistenceIndicate session persistence support
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_post_raw_field()

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]urlURL of HTTP request
[in]lenMax length of HTTP response data
[in]p_infPointer to HTTP_INF_H_S
[in]field_flagsThe http_hdr_field_sel_t, OR of zero or more flags
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_put()

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]urlURL of HTTP request
[in]callbackHandler of HTTP response
[in]datadata of HTTP request
[in]lenlength of HTTP request data
[in]add_head_cbHook before HTTP request sent, to add more HTTP header
[in]add_head_dataHeader data of add_head_cb
[in]pri_dataPrivate data used by HTTP request
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_put_custom_content()

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]urlURL of HTTP request
[in]callbackHandler of HTTP response
[in]p_ctxContext of HTTP request customized
[in]add_head_cbHook before HTTP request sent, to add more HTTP header
[in]add_head_dataHeader data of add_head_cb
[in]pri_dataPrivate data used by HTTP request
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_put_raw_field()

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]urlURL of HTTP request
[in]lenMax length of HTTP response data
[in]p_infPointer to HTTP_INF_H_S
[in]add_head_cbHook before HTTP request sent, to add more HTTP header
[in]add_head_dataHeader data of add_head_cb
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_client_set_session_timeout()

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_mssession timeout in millisecond
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_close_raw()

OPERATE_RET http_inf_close_raw ( INOUT HTTP_INF_H_S p_inf)

This API is used to close raw HTTP request

参数
[in]p_infPointer to HTTP_INF_H_S
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ http_inf_com_hanle_with_tls_config()

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
返回
OPERATE_RET

◆ http_inf_write_content_raw()

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_infPointer to HTTP_INF_H_S
[in]p_dataBuffer to write of HTTP request
[in]buf_lenMax length of HTTP request data
[in]chunkedChunk is enabled or not
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ httpc_inf_read_content_raw()

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_infPointer to HTTP_INF_H_S
[in]bufBuffer to read HTTP response
[in]buf_lenMax length of HTTP response data
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ httpc_inf_read_header_raw()

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_infPointer to HTTP_INF_H_S
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h