Add minimal HTTP GET test

The test does a request and prints the responses. It is done to see that
the functionality works. Also added a timeout of 10 seconds to both the
connection and data transfer phases.
This commit is contained in:
Markus Mäkelä
2018-08-19 08:02:04 +03:00
parent f8fb9510c9
commit 934600f8fc
2 changed files with 18 additions and 0 deletions

View File

@ -1248,6 +1248,9 @@ Result get(const std::string& url)
char errbuf[CURL_ERROR_SIZE + 1] = "";
CURL* curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10); // For connection phase
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); // For data transfer phase
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &res.raw_body);