C++ libcurl framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cppurl/test/test.cpp

65 lines
1.4 KiB

1 year ago
#include <iostream>
12 months ago
#include <vector>
#include <thread>
#include <future>
#include <string>
1 year ago
#include "../lib/cppurl.hpp"
using namespace std;
using namespace marcelb;
int main () {
12 months ago
// Curl rest;
// string header_value = "jebiga";
// rest.header("API", header_value);
// cout << rest.get("https://reqres.in/api/users/2") << endl;
1 year ago
12 months ago
// vector<thread> thr;
1 year ago
12 months ago
// for (uint i=0; i<4; i++) {
// thr.push_back(thread([](){
// Curl rest;
// string header_value = "jebiga";
// rest.header("API", header_value);
// cout << rest.get("https://reqres.in/api/users/2") << endl;
// }));
// }
// for (uint i=0; i<thr.size(); i++) {
// thr[i].join();
// }
// thread t1([](){
// Curl rest;
// cout << rest.get("https://reqres.in/api/users/2") << endl;
// });
// // t1.join();
// thread t2([](){
// Curl rest;
// cout << rest.get("https://reqres.in/api/users/2") << endl;
// });
// t1.join();
// t2.join();
vector<future<string>> debx_responses;
for (uint i=0; i<4; i++) {
debx_responses.push_back(async(launch::async, [&](){
Curl rest;
rest.timeout(600);
return rest.get("https://reqres.iin/api/users/2");
}));
}
for (uint i=0; i<4; i++) {
cout << debx_responses[i].get() << endl << endl;
}
1 year ago
}