- Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathhttps.h
More file actions
Latest commit
101 lines (75 loc) · 2.17 KB
/
Copy pathhttps.h
File metadata and controls
101 lines (75 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//
// Created by HISONA on 2016. 2. 29..
//
#ifndefHTTPS_CLIENT_HTTPS_H
#defineHTTPS_CLIENT_HTTPS_H
/*---------------------------------------------------------------------*/
#include"mbedtls/net.h"
#include"mbedtls/entropy.h"
#include"mbedtls/ctr_drbg.h"
#include"mbedtls/error.h"
#include"mbedtls/certs.h"
/*---------------------------------------------------------------------*/
#defineH_FIELD_SIZE 512
#defineH_READ_SIZE 2048
#undef TRUE
#undef FALSE
#defineTRUE 1
#defineFALSE 0
typedefunsigned charBOOL;
typedefstruct
{
charmethod[8];
intstatus;
charcontent_type[H_FIELD_SIZE];
longcontent_length;
BOOLchunked;
BOOLclose;
charlocation[H_FIELD_SIZE];
charreferrer[H_FIELD_SIZE];
charcookie[H_FIELD_SIZE];
charboundary[H_FIELD_SIZE];
} HTTP_HEADER;
typedefstruct
{
BOOLverify;
mbedtls_net_contextssl_fd;
mbedtls_entropy_contextentropy;
mbedtls_ctr_drbg_contextctr_drbg;
mbedtls_ssl_contextssl;
mbedtls_ssl_configconf;
mbedtls_x509_crtcacert;
} HTTP_SSL;
typedefstruct {
BOOLhttps;
charhost[256];
charport[8];
charpath[H_FIELD_SIZE];
} HTTP_URL;
typedefstruct
{
HTTP_URLurl;
HTTP_HEADERrequest;
HTTP_HEADERresponse;
HTTP_SSLtls;
longlength;
charr_buf[H_READ_SIZE];
longr_len;
BOOLheader_end;
char*body;
longbody_size;
longbody_len;
} HTTP_INFO;
/*---------------------------------------------------------------------*/
char*strtoken(char*src, char*dst, intsize);
inthttp_init(HTTP_INFO*hi, BOOLverify);
inthttp_close(HTTP_INFO*hi);
inthttp_get(HTTP_INFO*hi, char*url, char*response, intsize);
inthttp_post(HTTP_INFO*hi, char*url, char*data, char*response, intsize);
voidhttp_strerror(char*buf, intlen);
inthttp_open(HTTP_INFO*hi, char*url);
inthttp_write_header(HTTP_INFO*hi);
inthttp_write(HTTP_INFO*hi, char*data, intlen);
inthttp_write_end(HTTP_INFO*hi);
inthttp_read_chunked(HTTP_INFO*hi, char*response, intsize);
#endif//HTTPS_CLIENT_HTTPS_H