While at it, honour timeout parameter as well for DoT.
return url.substr(pos, endpos-pos);
}
-void MiniCurl::setupURL(const std::string& str, const ComboAddress* rem, const ComboAddress* src, int timeout)
+void MiniCurl::setupURL(const std::string& str, const ComboAddress* rem, const ComboAddress* src, int timeout, bool fastopen)
{
if(rem) {
struct curl_slist *hostlist = nullptr; // THIS SHOULD BE FREED
curl_easy_setopt(d_curl, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(d_curl, CURLOPT_WRITEDATA, this);
curl_easy_setopt(d_curl, CURLOPT_TIMEOUT, static_cast<long>(timeout));
+ curl_easy_setopt(d_curl, CURLOPT_TCP_FASTOPEN, fastopen);
clearHeaders();
d_data.clear();
return ret;
}
-std::string MiniCurl::postURL(const std::string& str, const std::string& postdata, MiniCurlHeaders& headers, int timeout)
+std::string MiniCurl::postURL(const std::string& str, const std::string& postdata, MiniCurlHeaders& headers, int timeout, bool fastopen)
{
- setupURL(str, nullptr, nullptr, timeout);
+ setupURL(str, nullptr, nullptr, timeout, fastopen);
setHeaders(headers);
curl_easy_setopt(d_curl, CURLOPT_POSTFIELDSIZE, postdata.size());
curl_easy_setopt(d_curl, CURLOPT_POSTFIELDS, postdata.c_str());
~MiniCurl();
MiniCurl& operator=(const MiniCurl&) = delete;
std::string getURL(const std::string& str, const ComboAddress* rem=nullptr, const ComboAddress* src=nullptr, int timeout = 2);
- std::string postURL(const std::string& str, const std::string& postdata, MiniCurlHeaders& headers, int timeout = 2);
+ std::string postURL(const std::string& str, const std::string& postdata, MiniCurlHeaders& headers, int timeout = 2, bool fastopen = false);
private:
CURL *d_curl;
static size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata);
std::string d_data;
struct curl_slist* d_header_list = nullptr;
- void setupURL(const std::string& str, const ComboAddress* rem=nullptr, const ComboAddress* src=nullptr, int timeout = 2);
+ void setupURL(const std::string& str, const ComboAddress* rem=nullptr, const ComboAddress* src=nullptr, int timeout = 2, bool fastopen = false);
void setHeaders(const MiniCurlHeaders& headers);
void clearHeaders();
};
mch.insert(std::make_pair("Accept", "application/dns-message"));
string question(packet.begin(), packet.end());
// FIXME: how do we use proxyheader here?
- reply = mc.postURL(argv[1], question, mch);
+ reply = mc.postURL(argv[1], question, mch, timeout, fastOpen);
printReply(reply, showflags, hidesoadetails);
#else
throw PDNSException("please link sdig against libcurl for DoH support");