elnormous / HTTPRequest

Single-header C++ HTTP request class
The Unlicense
942 stars 213 forks source link

Timeout not implementable #40

Closed ghost closed 2 years ago

ghost commented 3 years ago

I just want to understand what i am doing wrong :/

string webRequest(std::string path) { try { http::Request request{ serverUrl + path }; const auto response = request.send("GET", std::chrono::seconds(2)); // <--- Error pointed (When i remove the chrono, it works but the request never get any timeout, so never catched std::cout << "RESPONSe : " << response.status; return std::string{ response.body.begin(), response.body.end() }; } catch (const std::exception& e) { std::cout << e.what(); return ""; // Failed, don't crash but return no response. } }

Error (active) E0304 no instance of overloaded function "http::Request::send" matches the argument list

Meisam-Azad commented 2 years ago

To set timeout you should use this format: std::chrono::milliseconds{ 100 }

Use braces instead of parentheses

ghost commented 2 years ago

To set timeout you should use this format: std::chrono::milliseconds{ 100 }

Use braces instead of parentheses

Thanks you so much i waited 1 year for your help