|
|
|
@ -1,4 +1,8 @@ |
|
|
|
|
#include <iostream> |
|
|
|
|
#include <vector> |
|
|
|
|
#include <thread> |
|
|
|
|
#include <future> |
|
|
|
|
#include <string> |
|
|
|
|
|
|
|
|
|
#include "../lib/cppurl.hpp" |
|
|
|
|
|
|
|
|
@ -7,11 +11,55 @@ using namespace marcelb; |
|
|
|
|
|
|
|
|
|
int main () { |
|
|
|
|
|
|
|
|
|
// Curl rest;
|
|
|
|
|
// string header_value = "jebiga";
|
|
|
|
|
// rest.header("API", header_value);
|
|
|
|
|
// cout << rest.get("https://reqres.in/api/users/2") << endl;
|
|
|
|
|
|
|
|
|
|
// vector<thread> thr;
|
|
|
|
|
|
|
|
|
|
// 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"); |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rest.header("Baba", "Janja").useragent("Dinio api client v1.1.0 - bitelex@bitelex.co"); |
|
|
|
|
cout << rest.get("http://localhost:5000/?param1=tvt¶m2=2023") << endl; |
|
|
|
|
// cout << rest.request("https://reqres.in/api/users/2") << endl;
|
|
|
|
|
for (uint i=0; i<4; i++) { |
|
|
|
|
cout << debx_responses[i].get() << endl << endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |