物联网操作系统AliOS Things 3.3 |
结构体 | |
| struct | httpclient_t |
| This structure defines the httpclient_t structure 更多... | |
| struct | httpclient_data_t |
| This structure defines the HTTP data structure. 更多... | |
枚举 | |
| enum | HTTP_REQUEST_TYPE { HTTP_DELETE , HTTP_GET , HTTP_HEAD , HTTP_POST , HTTP_PUT } |
| http requst type 更多... | |
| enum | HTTPC_RESULT { HTTP_EAGAIN = 1 , HTTP_SUCCESS = 0 , HTTP_ENOBUFS = -1 , HTTP_EARG = -2 , HTTP_ENOTSUPP = -3 , HTTP_EDNS = -4 , HTTP_ECONN = -5 , HTTP_ESEND = -6 , HTTP_ECLSD = -7 , HTTP_ERECV = -8 , HTTP_EPARSE = -9 , HTTP_EPROTO = -10 , HTTP_EUNKOWN = -11 , HTTP_ETIMEOUT = -12 } |
| http error code 更多... | |
变量 | |
| int | socket |
| int | remote_port |
| int | response_code |
| char * | header |
| char * | auth_user |
| char * | auth_password |
| bool | is_http |
| bool | is_more |
| bool | is_chunked |
| int | retrieve_len |
| int | response_content_len |
| int | content_block_len |
| int | post_buf_len |
| int | response_buf_len |
| int | header_buf_len |
| char * | post_content_type |
| char * | post_buf |
| char * | response_buf |
| char * | header_buf |
| bool | is_redirected |
| char * | redirect_url |
| enum HTTP_REQUEST_TYPE |
| enum HTTPC_RESULT |
http error code
在文件 httpclient.h 第 30 行定义.
| void httpclient_clse | ( | httpclient_t * | client | ) |
| HTTPC_RESULT httpclient_conn | ( | httpclient_t * | client, |
| const char * | url | ||
| ) |
This function establish http/https connection.
| [in] | client | pointer to the httpclient_t. |
| [in] | url | remote URL |
| HTTPC_RESULT httpclient_delete | ( | httpclient_t * | client, |
| const char * | url, | ||
| httpclient_data_t * | client_data | ||
| ) |
This function executes a DELETE request on a given URL. It blocks until completion.
| [in] | client | client is a pointer to the httpclient_t. |
| [in] | url | url is the URL to run the request. |
| [in,out] | client_data | client_data is a pointer to the httpclient_data_t instance to collect the data returned by the request. |
| int httpclient_formdata_addfile | ( | httpclient_data_t * | client_data, |
| char * | content_disposition, | ||
| char * | name, | ||
| char * | content_type, | ||
| char * | file_path | ||
| ) |
This function add file formdata information.
| [in] | client_data | client_data is a pointer to the httpclient_data_t. |
| [in] | content_disposition | content_disposition is a pointer to the content disposition string. |
| [in] | content_type | content_type is a pointer to the content type string. |
| [in] | file_path | file_path is a pointer to the file path. |
| int httpclient_formdata_addtext | ( | httpclient_data_t * | client_data, |
| char * | content_disposition, | ||
| char * | content_type, | ||
| char * | name, | ||
| char * | data, | ||
| int | data_len | ||
| ) |
This function add text formdata information.
| [in] | client_data | client_data is a pointer to the httpclient_data_t. |
| [in] | content_disposition | content_disposition is a pointer to the content disposition string. |
| [in] | content_type | content_type is a pointer to the content type string. |
| [in] | name | name is a pointer to the name string. |
| [in] | data | data is a pointer to the data. |
| [in] | data_len | data_len is the data length. |
| HTTPC_RESULT httpclient_get | ( | httpclient_t * | client, |
| const char * | url, | ||
| httpclient_data_t * | client_data | ||
| ) |
This function executes a GET request on a given URL. It blocks until completion.
| [in] | client | client is a pointer to the httpclient_t. |
| [in] | url | url is the URL to run the request. |
| [in,out] | client_data | client_data is a pointer to the httpclient_data_t instance to collect the data returned by the request. |
| int httpclient_get_response_code | ( | httpclient_t * | client | ) |
This function gets the HTTP response code assigned to the last request.
| [in] | client | client is a pointer to the httpclient_t. |
| int httpclient_get_response_header_value | ( | char * | header_buf, |
| char * | name, | ||
| int * | val_pos, | ||
| int * | val_len | ||
| ) |
This function get specified response header value.
| [in] | header_buf | header_buf is the response header buffer. |
| [in] | name | name is the specified http response header name. |
| [in,out] | val_pos | val_pos is the position of header value in header_buf. |
| [in,out] | val_len | val_len is header value length. |
| HTTPC_RESULT httpclient_head | ( | httpclient_t * | client, |
| const char * | url, | ||
| httpclient_data_t * | client_data | ||
| ) |
This function executes a HEAD request on a given URL. It blocks until completion.
| [in] | client | client is a pointer to the httpclient_t. |
| [in] | url | url is the URL to run the request. |
| [in,out] | client_data | client_data is a pointer to the httpclient_data_t instance to collect the data returned by the request. |
| HTTPC_RESULT httpclient_post | ( | httpclient_t * | client, |
| const char * | url, | ||
| httpclient_data_t * | client_data | ||
| ) |
This function executes a POST request on a given URL. It blocks until completion.
| [in] | client | client is a pointer to the httpclient_t. |
| [in] | url | url is the URL to run the request. |
| [in,out] | client_data | client_data is a pointer to the httpclient_data_t instance to collect the data returned by the request. It also contains the data to be posted. |
| HTTPC_RESULT httpclient_prepare | ( | httpclient_data_t * | client_data, |
| int | header_size, | ||
| int | resp_size | ||
| ) |
This function allocates buffer for http header/response
| [in] | client_data | pointer to the httpclient_data_t. |
| [in] | header_size | header buffer size |
| [in] | resp_size | response buffer size |
| HTTPC_RESULT httpclient_put | ( | httpclient_t * | client, |
| const char * | url, | ||
| httpclient_data_t * | client_data | ||
| ) |
This function executes a PUT request on a given URL. It blocks until completion.
| [in] | client | client is a pointer to the httpclient_t. |
| [in] | url | url is the URL to run the request. |
| [in,out] | client_data | client_data is a pointer to the httpclient_data_t instance to collect the data returned by the request. It also contains the data to be put. |
| HTTPC_RESULT httpclient_recv | ( | httpclient_t * | client, |
| httpclient_data_t * | client_data | ||
| ) |
This function receives response from remote
| [in] | client | a pointer to httpclient_t. |
| [out] | client_data | a pointer to httpclient_data_t. |
| void httpclient_reset | ( | httpclient_data_t * | client_data | ) |
This function reset buffer for http header/response.
| [in] | client_data | pointer to the httpclient_data_t. |
| HTTPC_RESULT httpclient_send | ( | httpclient_t * | client, |
| const char * | url, | ||
| int | method, | ||
| httpclient_data_t * | client_data | ||
| ) |
This function sends HTTP request.
| [in] | client | a pointer to the httpclient_t. |
| [in] | url | remote URL |
| [in] | method | http request method |
| [in] | client_data | a pointer to httpclient_data_t. |
| void httpclient_set_custom_header | ( | httpclient_t * | client, |
| char * | header | ||
| ) |
This function sets a custom header.
| [in] | client | client is a pointer to the httpclient_t. |
| [in] | header | header is a custom header string. |
| HTTPC_RESULT httpclient_unprepare | ( | httpclient_data_t * | client_data | ) |
This function deallocates buffer for http header/response.
| [in] | client_data | pointer to the httpclient_data_t. |
| char* auth_password |
password for basic authentication
在文件 httpclient.h 第 54 行定义.
| char* auth_user |
username for basic authentication
在文件 httpclient.h 第 53 行定义.
| int content_block_len |
the content length of one block.
在文件 httpclient.h 第 73 行定义.
| char* header |
request custom header
在文件 httpclient.h 第 52 行定义.
| char* header_buf |
buffer to store the response head data.
在文件 httpclient.h 第 80 行定义.
| int header_buf_len |
response head buffer lehgth.
在文件 httpclient.h 第 76 行定义.
| bool is_chunked |
response data is encoded in portions/chunks.
在文件 httpclient.h 第 70 行定义.
| bool is_http |
http connection? if 1, http; if 0, https
在文件 httpclient.h 第 55 行定义.
| bool is_more |
indicates if more data needs to be retrieved.
在文件 httpclient.h 第 69 行定义.
| bool is_redirected |
redirected URL? if 1, has redirect url; if 0, no redirect url
在文件 httpclient.h 第 81 行定义.
| char* post_buf |
user data to be posted.
在文件 httpclient.h 第 78 行定义.
| int post_buf_len |
post data length.
在文件 httpclient.h 第 74 行定义.
| char* post_content_type |
content type of the post data.
在文件 httpclient.h 第 77 行定义.
| char* redirect_url |
redirect url when got http 3** response code.
在文件 httpclient.h 第 82 行定义.
| int remote_port |
hTTP or HTTPS port
在文件 httpclient.h 第 50 行定义.
| char* response_buf |
buffer to store the response body data.
在文件 httpclient.h 第 79 行定义.
| int response_buf_len |
response body buffer length.
在文件 httpclient.h 第 75 行定义.
| int response_code |
response code
在文件 httpclient.h 第 51 行定义.
| int response_content_len |
response content length.
在文件 httpclient.h 第 72 行定义.
| int retrieve_len |
content length to be retrieved.
在文件 httpclient.h 第 71 行定义.
| int socket |
socket ID
在文件 httpclient.h 第 49 行定义.