cpr
cpr copied to clipboard
Timeout for WriteCallback
cpr::Response r = cpr::Get(cpr::Url{"https://streaming/api"},
cpr::Timeout{10000},
sslOpts,
cpr::WriteCallback([&](std::string response_line)
{
std::cout << "tick" << endl;
}
This get will only wait 10 seconds and then it will stop executing. I want to put a timeout in case I don't receive a response in 10 secs using a WriteCallback. Is there any way to do this?
Hmm. I'm not aware of any solution for this. Any chance you know a way to do this is libcurl?
I think CURLOPT_CONNECTTIMEOUT can be used in this case but i am not sure how to do it using cpr::WriteCallback. i can check test if that is the correct way to go and open a PR for this.
@ishansheth this would be great!
@COM8 I noticed that there is already the implementation of cpr::ConnectTimeout
for this issue, so this issue could be closed as well.