16 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_LIBCURLUTILS_CURLEASYHANDLEWRAPPER_H_ 17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_LIBCURLUTILS_CURLEASYHANDLEWRAPPER_H_ 20 #include <curl/curl.h> 29 #ifdef ACSDK_EMIT_SENSITIVE_LOGS 30 #define ACSDK_EMIT_CURL_LOGS 36 namespace libcurlUtils {
38 class CurlEasyHandleWrapper;
53 template <
typename ParamType>
54 bool setopt(CURLoption option, ParamType param);
73 using CurlCallback = size_t (*)(
char* buffer,
size_t blockSize,
size_t numBlocks,
void* userData);
85 int (*)(CURL* handle, curl_infotype infoType,
char* buffer,
size_t blockSize,
void* userData);
133 CURL* getCurlHandle();
188 bool setTransferTimeout(
const long timeoutSeconds);
206 bool setConnectionTimeout(
const std::chrono::seconds timeoutSeconds);
215 bool setWriteCallback(
CurlCallback callback,
void* userData);
225 bool setHeaderCallback(
CurlCallback callback,
void* userData);
234 bool setReadCallback(
CurlCallback callback,
void* userData);
249 long getHTTPResponseCode();
274 CURLcode pause(
int mask);
288 static void setInterfaceName(
const std::string& interfaceName);
307 template <
typename ParamType>
308 bool setopt(CURLoption option, ParamType param);
318 void cleanupResources();
325 bool setDefaultOptions();
327 #ifdef ACSDK_EMIT_CURL_LOGS 331 void initStreamLog();
343 static int debugFunction(CURL* handle, curl_infotype type,
char* data,
size_t size,
void* user);
347 static void initializeNetworkInterfaceNameLocked();
352 curl_slist* m_requestHeaders;
354 curl_slist* m_postHeaders;
356 curl_httppost* m_post;
358 curl_httppost* m_lastPost;
362 static std::mutex m_interfaceNameMutex;
364 static bool m_isInterfaceNameInitialized;
368 static std::atomic<uint64_t> m_idGenerator;
373 std::unique_ptr<std::ofstream> m_streamLog;
375 std::unique_ptr<std::ofstream> m_streamInDump;
377 std::unique_ptr<std::ofstream> m_streamOutDump;
384 template <
typename ParamType>
385 bool CurlEasyHandleWrapper::setopt(CURLoption option, ParamType value) {
387 if (result != CURLE_OK) {
389 .d(
"reason",
"curl_easy_setopt failed")
391 .sensitive(
"value", value)
393 .d(
"error", curl_easy_strerror(result)));
399 template <
typename ParamType>
401 return m_easyHandleWrapper->setopt(option, std::forward<ParamType>(value));
409 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_LIBCURLUTILS_CURLEASYHANDLEWRAPPER_H_ bool setopt(CURLoption option, ParamType param)
Definition: CurlEasyHandleWrapper.h:400
Definition: CurlEasyHandleWrapper.h:63
::std::string string
Definition: gtest-port.h:1097
CurlEasyHandleWrapperOptionsSettingAdapter(CurlEasyHandleWrapper *wrapper)
Definition: CurlEasyHandleWrapper.h:43
Definition: CurlEasyHandleWrapper.h:41
CURLcode curl_easy_setopt(CURL *curl, CURLoption option,...)
Definition: CurlWrapperMock.cpp:87
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
size_t(*)(char *buffer, size_t blockSize, size_t numBlocks, void *userData) CurlCallback
Definition: CurlEasyHandleWrapper.h:73
type
Definition: upload.py:443
void acsdkError(const LogEntry &entry)
TransferType
Definition: CurlEasyHandleWrapper.h:90
int(*)(CURL *handle, curl_infotype infoType, char *buffer, size_t blockSize, void *userData) CurlDebugCallback
Definition: CurlEasyHandleWrapper.h:85
LogEntry is used to compile the log entry text to log via Logger.
Definition: LogEntry.h:33