VSF Documented
vsf_http_client.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_HTTP_CLIENT_H__
19#define __VSF_HTTP_CLIENT_H__
20
21/*============================ INCLUDES ======================================*/
22
24
25#if defined(__VSF_HTTP_CLIENT_CLASS_IMPLEMENT)
26# define __VSF_CLASS_IMPLEMENT__
27#elif defined(__VSF_HTTP_CLIENT_CLASS_INHERIT__)
28# define __VSF_CLASS_INHERIT__
29#endif
30
31#include "utilities/ooc_class.h"
32
33/*============================ MACROS ========================================*/
34/*============================ MACROFIED FUNCTIONS ===========================*/
35/*============================ TYPES =========================================*/
36
38 protected_member(
39 int (*fn_connect)(void *param, const char *host, const char *port);
40 void (*fn_close)(void *param);
41 int (*fn_write)(void *param, uint8_t *buf, uint16_t len);
42 int (*fn_read)(void *param, uint8_t *buf, uint16_t len);
43 )
44};
45
46typedef struct vsf_http_client_req_t {
47 const char *host;
48 const char *port;
49 const char *verb;
50
51 char *header;
52 char *path;
53
55 size_t txdata_len;
57
59 public_member(
60 const vsf_http_op_t *op;
61 void *param;
62 int resp_status;
63 int content_length;
64 )
65 private_member(
66 uint16_t cur_size;
67 bool is_chunked;
68 int cur_chunk_size;
69 uint8_t *cur_buffer;
70 uint8_t buffer[1024];
71 )
72};
73
74/*============================ GLOBAL VARIABLES ==============================*/
75
76#if VSF_USE_MBEDTLS == ENABLED
77// to use mbedtls_http_op, user source code(.c) MUST include
78// "component/3rd-party/mbedtls/extension/tls_session/mbedtls_tls_session.h",
79// and set mbedtls_session_t instance to param of vsf_http_client_t.
81#endif
82
83/*============================ PROTOTYPES ====================================*/
84
88extern int vsf_http_client_read(vsf_http_client_t *http, uint8_t *buf, uint16_t len);
89
90#endif // __VSF_HTTP_CLIENT_H__
Definition vsf_http_client.h:58
Definition vsf_http_client.h:37
#define vsf_class(__name)
Definition ooc_class.h:48
unsigned short uint16_t
Definition stdint.h:7
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_http_client.h:46
const char * verb
Definition vsf_http_client.h:49
uint8_t * txdata
Definition vsf_http_client.h:54
char * header
Definition vsf_http_client.h:51
const char * host
Definition vsf_http_client.h:47
size_t txdata_len
Definition vsf_http_client.h:55
const char * port
Definition vsf_http_client.h:48
char * path
Definition vsf_http_client.h:52
void vsf_http_client_close(vsf_http_client_t *http)
Definition vsf_http_client.c:74
const vsf_http_op_t vsf_mbedtls_http_op
Definition vsf_http_client.c:47
void vsf_http_client_init(vsf_http_client_t *http)
Definition vsf_http_client.c:69
int vsf_http_client_request(vsf_http_client_t *http, vsf_http_client_req_t *req)
Definition vsf_http_client.c:79
int vsf_http_client_read(vsf_http_client_t *http, uint8_t *buf, uint16_t len)
Definition vsf_http_client.c:179