-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhttp.h
56 lines (42 loc) · 1.21 KB
/
http.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
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* This file is part of the sse package, copyright (c) 2011, 2012, @radiospiel.
* It is copyrighted under the terms of the modified BSD license, see LICENSE.BSD.
*
* For more information see https://https://github.com/radiospiel/sse.
*/
#ifndef HTTP_H
#define HTTP_H
#include <string.h>
#include <curl/curl.h>
#include <functional>
/*
* send HTTP request.
*/
enum HttpVerb {
HTTP_GET = 0,
HTTP_POST = 1,
};
typedef std::function<size_t(char*, size_t, size_t)> OnDataFunc;
typedef std::function<size_t(curl_off_t, curl_off_t, curl_off_t, curl_off_t)> OnProgressFunc;
bool http(HttpVerb verb,
const char* url,
const char** http_headers,
const char* body,
unsigned bodyLenght,
OnDataFunc on_data = {},
const std::function<const char*(CURL*)>& on_verify = {},
OnProgressFunc progress_callback = {}
);
/*
* Aplication options
*/
struct Options {
const char *arg0; // process name
int limit; // event limit
int verbosity; // verbosity
int allow_insecure; // allow insecure connections
const char *ssl_cert; // SSL cert file
const char *ca_info; // CA cert file
};
extern Options options;
#endif