-
Notifications
You must be signed in to change notification settings - Fork 9
/
https.h
43 lines (32 loc) · 1.2 KB
/
https.h
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
/*
* https.h
*
* Copyright (c) 2011 Duo Security
* All rights reserved, all wrongs reversed.
*/
#ifndef HTTPS_H
#define HTTPS_H
typedef struct https_request https_t;
#define DUO_NO_TIMEOUT -1
typedef enum {
HTTPS_OK,
HTTPS_ERR_SYSTEM, /* system problem */
HTTPS_ERR_LIB, /* library problem */
HTTPS_ERR_CLIENT, /* something you did */
HTTPS_ERR_SERVER, /* something the server did */
} HTTPScode;
/* Initialize HTTPS library - do this once! */
HTTPScode https_init(const char *useragent, const char *cafile,
const char *proxy);
/* Open HTTPS connection to host[:port] */
HTTPScode https_open(https_t **hp, const char *host);
/* Send request, return 0 for success or -1 on error */
HTTPScode https_send(https_t *h, const char *method, const char *uri,
const char *qs, const char *hdrs);
/* Read response, return HTTP status code, set body and length if available */
HTTPScode https_recv(https_t *h, int *code, const char **body, int *length, int msecs_timeout);
/* Return and clear last API error */
const char *https_geterr(void);
/* Close HTTP connection */
void https_close(https_t **hp);
#endif /* HTTPS_H */