![]() |
AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <HTTPContentFetcherInterface.h>
Classes | |
struct | Header |
Public Types | |
enum | FetchOptions { FetchOptions::CONTENT_TYPE, FetchOptions::ENTIRE_BODY } |
Represents what HTTP content to fetch. More... | |
enum | State { State::INITIALIZED, State::FETCHING_HEADER, State::HEADER_DONE, State::FETCHING_BODY, State::BODY_DONE, State::ERROR } |
The state of payload fetching. More... | |
Public Member Functions | |
virtual | ~HTTPContentFetcherInterface ()=default |
virtual State | getState ()=0 |
virtual std::string | getUrl () const =0 |
virtual std::string | getEffectiveUrl () const =0 |
virtual Header | getHeader (std::atomic< bool > *shouldShutdown)=0 |
virtual bool | getBody (std::shared_ptr< avsCommon::avs::attachment::AttachmentWriter > writer)=0 |
virtual void | shutdown ()=0 |
virtual 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 >())=0 |
Static Public Member Functions | |
static std::string | getUserAgent () |
static std::string | stateToString (State state) |
This class allows users to fetch content from remote location using HTTP(S).
The state of payload fetching.
|
virtualdefault |
Destructor.
|
pure virtual |
Retrieves the body after the header was received. This method is asynchronous and the caller can monitor the download progress using the getState
method.
writer | The writer to write the payload. |
true
if the call is successful.
|
pure virtual |
This function retrieves content from a remote location. No thread safety is guaranteed.
option | Flag indicating desired content. |
writer | An optional writer parameter to be used when writing to an external stream. |
customHeaders | An optional list of headers to be attached to the request. |
HTTPContent
object or nullptr
if a failure occurred.
|
pure virtual |
Gets the effective URL associated with this content fetcher.
Implemented in alexaClientSDK::playlistParser::test::MockContentFetcher, alexaClientSDK::mediaPlayer::test::MockContentFetcher, and alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher.
|
pure virtual |
Waits until the header was fetched successfully. If any problem happened during header, returns false
. After the header was already fetched, this method can be called multiple times and will return immediately.
shouldShutdown | A pointer to allow for the caller to asynchronously cancel the wait, if needed. this argument is optional. If it is a null pointer, the function will ignore it. |
Implemented in alexaClientSDK::playlistParser::test::MockContentFetcher, alexaClientSDK::mediaPlayer::test::MockContentFetcher, and alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher.
|
pure virtual |
The current content fetching state. In particular, a caller of getBody
, an asynchronous function, can use this method to monitor the download progress.
Implemented in alexaClientSDK::playlistParser::test::MockContentFetcher, alexaClientSDK::mediaPlayer::test::MockContentFetcher, and alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher.
|
pure virtual |
Gets the URL associated with this content fetcher
Implemented in alexaClientSDK::playlistParser::test::MockContentFetcher, alexaClientSDK::mediaPlayer::test::MockContentFetcher, and alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher.
|
inlinestatic |
Returns a string that represents the User-Agent to be used in HTTP requests.
|
pure virtual |
Shuts down the content fetcher.
Implemented in alexaClientSDK::playlistParser::test::MockContentFetcher, alexaClientSDK::mediaPlayer::test::MockContentFetcher, and alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher.
|
inlinestatic |
Produces the string representation of the state enum values.
state | The state enum value. |
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0