AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | List of all members
alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher Class Reference

#include <LibCurlHttpContentFetcher.h>

Inheritance diagram for alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher:
Collaboration graph
[legend]

Public Member Functions

 LibCurlHttpContentFetcher (const std::string &url, const std::shared_ptr< LibcurlSetCurlOptionsCallbackInterface > &setCurlOptionsCallback=nullptr)
 
std::unique_ptr< avsCommon::utils::HTTPContentgetContent (FetchOptions option, std::unique_ptr< avsCommon::avs::attachment::AttachmentWriter > writer=nullptr, const std::vector< std::string > &customHeaders=std::vector< std::string >()) override
 
 ~LibCurlHttpContentFetcher () override
 
HTTPContentFetcherInterface methods
State getState () override
 
std::string getUrl () const override
 
std::string getEffectiveUrl () const override
 
Header getHeader (std::atomic< bool > *shouldShutdown) override
 
bool getBody (std::shared_ptr< avsCommon::avs::attachment::AttachmentWriter > writer) override
 
void shutdown () override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::HTTPContentFetcherInterface
virtual ~HTTPContentFetcherInterface ()=default
 
virtual bool getBody (std::shared_ptr< avsCommon::avs::attachment::AttachmentWriter > writer)=0
 
virtual std::unique_ptr< avsCommon::utils::HTTPContentgetContent (FetchOptions option, std::unique_ptr< avsCommon::avs::attachment::AttachmentWriter > writer=nullptr, const std::vector< std::string > &customHeaders=std::vector< std::string >())=0
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::HTTPContentFetcherInterface
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...
 
- Static Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::HTTPContentFetcherInterface
static std::string getUserAgent ()
 
static std::string stateToString (State state)
 

Detailed Description

A class used to retrieve content from remote URLs. Note that this object will only write to the Attachment while it remains alive. If the object goes out of scope, writing to the Attachment will abort.

Constructor & Destructor Documentation

◆ LibCurlHttpContentFetcher()

alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher::LibCurlHttpContentFetcher ( const std::string &  url,
const std::shared_ptr< LibcurlSetCurlOptionsCallbackInterface > &  setCurlOptionsCallback = nullptr 
)
explicit

Constructor.

Parameters
urlThe url to fetch the content from.
setCurlOptionsCallbackThe optional LibcurlSetCurlOptionsCallbackInterface allows setting user defined curl options.

◆ ~LibCurlHttpContentFetcher()

alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher::~LibCurlHttpContentFetcher ( )
override

Member Function Documentation

◆ getBody()

bool alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher::getBody ( std::shared_ptr< avsCommon::avs::attachment::AttachmentWriter writer)
override

◆ getContent()

std::unique_ptr<avsCommon::utils::HTTPContent> alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher::getContent ( FetchOptions  option,
std::unique_ptr< avsCommon::avs::attachment::AttachmentWriter writer = nullptr,
const std::vector< std::string > &  customHeaders = std::vector< std::string >() 
)
override

In this implementation, the function may only be called once. Subsequent calls will return nullptr.

◆ getEffectiveUrl()

std::string alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher::getEffectiveUrl ( ) const
overridevirtual

Gets the effective URL associated with this content fetcher.

Note
This is useful in the case of redirects where the first URL used redirects to a different URL to fetch the content.
Returns
The content fetcher's effective URL.

Implements alexaClientSDK::avsCommon::sdkInterfaces::HTTPContentFetcherInterface.

◆ getHeader()

Header alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher::getHeader ( std::atomic< bool > *  shouldShutdown)
overridevirtual

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.

Parameters
shouldShutdownA 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.
Returns
The header struct. It is the caller's responsibility to check the struct to see if the header was retrieved successfully.

Implements alexaClientSDK::avsCommon::sdkInterfaces::HTTPContentFetcherInterface.

◆ getState()

State alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher::getState ( )
overridevirtual

The current content fetching state. In particular, a caller of getBody, an asynchronous function, can use this method to monitor the download progress.

Returns
The current content fetching state.

Implements alexaClientSDK::avsCommon::sdkInterfaces::HTTPContentFetcherInterface.

◆ getUrl()

std::string alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher::getUrl ( ) const
overridevirtual

Gets the URL associated with this content fetcher

Returns
The content fetcher URL

Implements alexaClientSDK::avsCommon::sdkInterfaces::HTTPContentFetcherInterface.

◆ shutdown()

void alexaClientSDK::avsCommon::utils::libcurlUtils::LibCurlHttpContentFetcher::shutdown ( )
overridevirtual

Shuts down the content fetcher.

Implements alexaClientSDK::avsCommon::sdkInterfaces::HTTPContentFetcherInterface.


The documentation for this class was generated from the following file:

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0