物联网操作系统AliOS Things 3.3
httpclient.h
浏览该文件的文档.
1 
10 #ifndef HTTPCLIENT_H
11 #define HTTPCLIENT_H
12 
13 #include <stdbool.h>
14 #include <stdint.h>
15 
21 typedef enum {
26  HTTP_PUT
28 
30 typedef enum {
34  HTTP_EARG = -2,
36  HTTP_EDNS = -4,
37  HTTP_ECONN = -5,
38  HTTP_ESEND = -6,
39  HTTP_ECLSD = -7,
40  HTTP_ERECV = -8,
42  HTTP_EPROTO = -10,
43  HTTP_EUNKOWN = -11,
45 } HTTPC_RESULT;
46 
48 typedef struct {
49  int socket;
52  char *header;
53  char *auth_user;
55  bool is_http;
56 #if CONFIG_HTTP_SECURE
57  const char *server_cert;
58  const char *client_cert;
59  const char *client_pk;
60  int server_cert_len;
61  int client_cert_len;
62  int client_pk_len;
63  void *ssl;
64 #endif
65 } httpclient_t;
66 
68 typedef struct {
69  bool is_more;
70  bool is_chunked;
78  char *post_buf;
79  char *response_buf;
80  char *header_buf;
82  char* redirect_url;
84 
92 HTTPC_RESULT httpclient_get(httpclient_t *client, const char *url, httpclient_data_t *client_data);
93 
101 HTTPC_RESULT httpclient_head(httpclient_t *client, const char *url, httpclient_data_t *client_data);
102 
110 HTTPC_RESULT httpclient_post(httpclient_t *client, const char *url, httpclient_data_t *client_data);
111 
119 HTTPC_RESULT httpclient_put(httpclient_t *client, const char *url, httpclient_data_t *client_data);
120 
128 HTTPC_RESULT httpclient_delete(httpclient_t *client, const char *url, httpclient_data_t *client_data);
129 
138 HTTPC_RESULT httpclient_prepare(httpclient_data_t *client_data, int header_size, int resp_size);
139 
147 
154 
161 HTTPC_RESULT httpclient_conn(httpclient_t *client, const char *url);
162 
171 HTTPC_RESULT httpclient_send(httpclient_t *client, const char *url, int method, httpclient_data_t *client_data);
172 
180 
187 
194 void httpclient_set_custom_header(httpclient_t *client, char *header);
195 
202 
211 int httpclient_get_response_header_value(char *header_buf, char *name, int *val_pos, int *val_len);
212 
223 int httpclient_formdata_addtext(httpclient_data_t* client_data, char* content_disposition, char* content_type, char* name, char* data, int data_len);
224 
233 int httpclient_formdata_addfile(httpclient_data_t* client_data, char* content_disposition, char* name, char* content_type, char* file_path);
234 
235 #endif /* HTTPCLIENT_H */
HTTPC_RESULT httpclient_unprepare(httpclient_data_t *client_data)
void httpclient_set_custom_header(httpclient_t *client, char *header)
char * header
Definition: httpclient.h:52
HTTPC_RESULT httpclient_recv(httpclient_t *client, httpclient_data_t *client_data)
HTTPC_RESULT httpclient_post(httpclient_t *client, const char *url, httpclient_data_t *client_data)
HTTPC_RESULT httpclient_conn(httpclient_t *client, const char *url)
HTTPC_RESULT httpclient_send(httpclient_t *client, const char *url, int method, httpclient_data_t *client_data)
char * response_buf
Definition: httpclient.h:79
int remote_port
Definition: httpclient.h:50
void httpclient_reset(httpclient_data_t *client_data)
int httpclient_get_response_code(httpclient_t *client)
bool is_http
Definition: httpclient.h:55
HTTPC_RESULT httpclient_head(httpclient_t *client, const char *url, httpclient_data_t *client_data)
int httpclient_formdata_addfile(httpclient_data_t *client_data, char *content_disposition, char *name, char *content_type, char *file_path)
HTTPC_RESULT
http error code
Definition: httpclient.h:30
void httpclient_clse(httpclient_t *client)
char * redirect_url
Definition: httpclient.h:82
int response_code
Definition: httpclient.h:51
int httpclient_get_response_header_value(char *header_buf, char *name, int *val_pos, int *val_len)
char * post_content_type
Definition: httpclient.h:77
char * auth_password
Definition: httpclient.h:54
HTTPC_RESULT httpclient_prepare(httpclient_data_t *client_data, int header_size, int resp_size)
HTTPC_RESULT httpclient_delete(httpclient_t *client, const char *url, httpclient_data_t *client_data)
char * auth_user
Definition: httpclient.h:53
HTTPC_RESULT httpclient_put(httpclient_t *client, const char *url, httpclient_data_t *client_data)
int response_content_len
Definition: httpclient.h:72
int httpclient_formdata_addtext(httpclient_data_t *client_data, char *content_disposition, char *content_type, char *name, char *data, int data_len)
HTTP_REQUEST_TYPE
http requst type
Definition: httpclient.h:21
HTTPC_RESULT httpclient_get(httpclient_t *client, const char *url, httpclient_data_t *client_data)
@ HTTP_EPARSE
Definition: httpclient.h:41
@ HTTP_ESEND
Definition: httpclient.h:38
@ HTTP_ECONN
Definition: httpclient.h:37
@ HTTP_EPROTO
Definition: httpclient.h:42
@ HTTP_ETIMEOUT
Definition: httpclient.h:44
@ HTTP_ERECV
Definition: httpclient.h:40
@ HTTP_ENOBUFS
Definition: httpclient.h:33
@ HTTP_ECLSD
Definition: httpclient.h:39
@ HTTP_EUNKOWN
Definition: httpclient.h:43
@ HTTP_SUCCESS
Definition: httpclient.h:32
@ HTTP_EARG
Definition: httpclient.h:34
@ HTTP_EAGAIN
Definition: httpclient.h:31
@ HTTP_EDNS
Definition: httpclient.h:36
@ HTTP_ENOTSUPP
Definition: httpclient.h:35
@ HTTP_PUT
Definition: httpclient.h:26
@ HTTP_DELETE
Definition: httpclient.h:22
@ HTTP_GET
Definition: httpclient.h:23
@ HTTP_POST
Definition: httpclient.h:25
@ HTTP_HEAD
Definition: httpclient.h:24
This structure defines the HTTP data structure.
Definition: httpclient.h:68
This structure defines the httpclient_t structure
Definition: httpclient.h:48