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

75 lines
1.8 KiB

11 months ago
#include <iostream>
10 months ago
#include <vector>
#include <thread>
#include <future>
#include <string>
11 months ago
#include "../lib/cppurl.hpp"
using namespace std;
using namespace marcelb;
int main () {
Curl rest;
8 months ago
string header_value = "3849f438uf9uedu8ejweoijwejd09230";
rest.header("API", header_value).timeout(700)
.httpv(HTTP2).sslverifyoff();
cout << rest.get("https://reqres.in/api/users/2") << endl <<
"Curl status " << rest.curlStatus << endl <<
8 months ago
"HTTP status " << rest.httpStatus << endl;
for (auto header : rest.responseHeader) {
cout << header.first << " " << header.second << endl;
}
11 months ago
10 months ago
// vector<thread> thr;
11 months ago
10 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;
10 months ago
// for (uint i=0; i<4; i++) {
// debx_responses.push_back(async(launch::async, [&](){
// Curl rest;
// // rest.timeout(6000);
// rest.sslverifyoff().httpv(HTTP2);
// return rest.get("https://lab-it.ddns.net");
// }));
// }
10 months ago
// for (uint i=0; i<4; i++) {
// // cout << debx_responses[i].get() << endl << endl;
// debx_responses[i].get();
// }
10 months ago
11 months ago
}