16 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_LIBCURLUTILS_LIBCURLHTTPCONTENTFETCHER_H_ 17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_LIBCURLUTILS_LIBCURLHTTPCONTENTFETCHER_H_ 31 namespace libcurlUtils {
48 const std::shared_ptr<LibcurlSetCurlOptionsCallbackInterface>& setCurlOptionsCallback =
nullptr);
56 bool getBody(std::shared_ptr<avsCommon::avs::attachment::AttachmentWriter> writer)
override;
63 std::unique_ptr<avsCommon::utils::HTTPContent>
getContent(
65 std::unique_ptr<avsCommon::avs::attachment::AttachmentWriter> writer =
nullptr,
66 const std::vector<std::string>& customHeaders = std::vector<std::string>())
override;
75 static size_t headerCallback(
char* data,
size_t size,
size_t nmemb,
void* userData);
78 static size_t bodyCallback(
char* data,
size_t size,
size_t nmemb,
void* userData);
81 static size_t noopCallback(
char* data,
size_t size,
size_t nmemb,
void* userData);
92 curl_slist* getCustomHeaderList(
const std::vector<std::string>& customHeaders);
98 mutable std::mutex m_effectiveUrlMutex;
107 std::promise<bool> m_headerPromise;
110 std::shared_future<bool> m_headerFuture;
118 std::shared_ptr<avsCommon::avs::attachment::AttachmentWriter> m_streamWriter;
121 ssize_t m_currentContentReceivedLength;
124 ssize_t m_totalContentReceivedLength;
127 std::atomic<bool> m_done;
130 std::atomic<bool> m_isShutdown;
136 std::thread m_thread;
139 std::atomic<bool> m_hasObjectBeenUsed;
142 std::mutex m_stateMutex;
148 std::mutex m_getBodyMutex;
156 void reportInvalidStateTransitionAttempt(
State currentState,
State newState);
166 void stateTransition(
State newState,
bool value);
172 bool waitingForBodyRequest();
178 void updateEffectiveURL();
186 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_LIBCURLUTILS_LIBCURLHTTPCONTENTFETCHER_H_ Definition: CurlEasyHandleWrapper.h:63
Definition: HTTPContentFetcherInterface.h:32
::std::string string
Definition: gtest-port.h:1097
bool getBody(std::shared_ptr< avsCommon::avs::attachment::AttachmentWriter > writer) override
State getState() override
~LibCurlHttpContentFetcher() override
std::unique_ptr< avsCommon::utils::HTTPContent > getContent(FetchOptions option, std::unique_ptr< avsCommon::avs::attachment::AttachmentWriter > writer=nullptr, const std::vector< std::string > &customHeaders=std::vector< std::string >()) override
std::string getEffectiveUrl() const override
State
The state of payload fetching.
Definition: HTTPContentFetcherInterface.h:43
std::string getUrl() const override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
Definition: LibCurlHttpContentFetcher.h:37
LibCurlHttpContentFetcher(const std::string &url, const std::shared_ptr< LibcurlSetCurlOptionsCallbackInterface > &setCurlOptionsCallback=nullptr)
FetchOptions
Represents what HTTP content to fetch.
Definition: HTTPContentFetcherInterface.h:35
Header getHeader(std::atomic< bool > *shouldShutdown) override