From c3d93684368c82c0d7f969997264c121cbaafabd Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 8 Mar 2018 21:19:21 +0000 Subject: Allow configuring referrer and useragent, also set a collection of other handy headers --- service/apiImpl.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'service/apiImpl.cpp') diff --git a/service/apiImpl.cpp b/service/apiImpl.cpp index ab86d98..9795769 100644 --- a/service/apiImpl.cpp +++ b/service/apiImpl.cpp @@ -86,6 +86,17 @@ namespace MirrorSearch { return size; }; CESSO(curl, CURLOPT_WRITEDATA, &cb); + if (ss->referrer) { + CESSO(curl, CURLOPT_REFERER, ss->referrer->c_str()); + } + if (ss->useragent) { + CESSO(curl, CURLOPT_USERAGENT, ss->useragent->c_str()); + } + CESSO(curl, CURLOPT_TIMEOUT, 5L); + // Enables compression + CESSO(curl, CURLOPT_ACCEPT_ENCODING, ""); + CESSO(curl, CURLOPT_HTTP_CONTENT_DECODING, 1L); + CESSO(curl, CURLOPT_TCP_FASTOPEN, 1L); if (curl_easy_perform(curl.get()) != CURLE_OK) { curlErrorHandler(failingFunction((void*)&curl_easy_perform), errbuf, url); } -- cgit v1.2.3