-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.cpp
30 lines (21 loc) · 881 Bytes
/
example.cpp
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
#include <iostream>
#include <string>
#include "curl4.hpp"
// raw c code taken from
// https://stackoverflow.com/questions/2329571/c-libcurl-get-output-into-a-string
int main() {
curl4::CURL4 init = curl4::easy::init();
std::string url = "https://raw.githubusercontent.com/ferhatgec/bufsize/master/example.cpp";
{
std::string val;
init.setopt(CURLOPT_URL, url);
init.setopt(CURLOPT_WRITEFUNCTION, curl4::easy::writefunc);
init.setopt(CURLOPT_WRITEDATA, &val);
// curl4::easy::setopt(init, CURLOPT_URL, "https://raw.githubusercontent.com/ferhatgec/bufsize/master/example.cpp");
// curl4::easy::setopt(init, CURLOPT_WRITEFUNCTION, writefunc);
// curl4::easy::setopt(init, CURLOPT_WRITEDATA, &val);
CURLcode res = curl4::easy::perform(init);
std::cout << val << '\n';
}
return 0;
}