AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Types | Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::acsdkAssets::common::CurlWrapper Class Reference

#include <CurlWrapper.h>

Public Types

using HeaderResults = avsCommon::utils::error::Result< commonInterfaces::ResultCode, std::string >
 Return status for header APIs. More...
 

Public Member Functions

virtual ~CurlWrapper ()
 
commonInterfaces::ResultCode get (const std::string &url, std::ostream &response, const std::weak_ptr< CurlProgressCallbackInterface > &callbackObj)
 
commonInterfaces::ResultCode download (const std::string &url, const std::string &path, const std::weak_ptr< CurlProgressCallbackInterface > &callbackObj, bool unpack=false, size_t size=0)
 
HeaderResults getHeaders (const std::string &url)
 
HeaderResults getHeadersAuthorized (const std::string &url)
 
commonInterfaces::ResultCode getAndDownloadMultipart (const std::string &url, std::shared_ptr< ResponseSink > sink, const std::weak_ptr< CurlProgressCallbackInterface > &callbackObj)
 

Static Public Member Functions

static std::unique_ptr< CurlWrappercreate (bool isThrottled, std::shared_ptr< alexaClientSDK::avsCommon::sdkInterfaces::AuthDelegateInterface > authDelegate, const std::string &certPath="")
 
static std::string getValueFromHeaders (const std::string &headers, const std::string &key)
 

Detailed Description

Wraps the libcurl library in a more C++ friendly manner. Still undecided if this will be generic or specific to DAVS. Likely will be DAVS specific.

Member Typedef Documentation

◆ HeaderResults

Return status for header APIs.

Constructor & Destructor Documentation

◆ ~CurlWrapper()

virtual alexaClientSDK::acsdkAssets::common::CurlWrapper::~CurlWrapper ( )
virtual

Member Function Documentation

◆ create()

static std::unique_ptr<CurlWrapper> alexaClientSDK::acsdkAssets::common::CurlWrapper::create ( bool  isThrottled,
std::shared_ptr< alexaClientSDK::avsCommon::sdkInterfaces::AuthDelegateInterface authDelegate,
const std::string &  certPath = "" 
)
static

Creates and initializes the object.

Parameters
isThrottledwhether the download should be slowed down for throttling
authDelegatethe Authentication Delegate to generate the authentication token
certPath- optional - a path to a local SSL cert to use instead of maplite
Returns
a valid smart pointer to a valid object that can be used, or nullptr in case of error

◆ download()

commonInterfaces::ResultCode alexaClientSDK::acsdkAssets::common::CurlWrapper::download ( const std::string &  url,
const std::string &  path,
const std::weak_ptr< CurlProgressCallbackInterface > &  callbackObj,
bool  unpack = false,
size_t  size = 0 
)

Synchronously download a remote URL to local file or directory (if unpack is needed)

Parameters
urlthe URL to download from
paththe absolute path to a file (or directory) to write to (if unpack is needed)
callbackObjobject that implements CurlProgressCallbackInterface
unpackwhether unpack is needed during download, size must be specified or download would fail.
sizesize of the file to be downloaded, if not specified or set to 0, size check will be skipped. (except when unpack=1)
Returns
SUCCESS if successfully downloaded Note: if return value is false, the file may be partially written to.

◆ get()

commonInterfaces::ResultCode alexaClientSDK::acsdkAssets::common::CurlWrapper::get ( const std::string &  url,
std::ostream &  response,
const std::weak_ptr< CurlProgressCallbackInterface > &  callbackObj 
)

Executes HTTP GET request and populates the response.

Parameters
urlIN, the URL to execute, must be a https. It should include any query parameters as well.
responseOUT, the ostream to populate with the HTTP entity-body; it may end up empty if entity-body is empty or not present.
callbackObjobject that implements CurlProgressCallbackInterface
Returns
ResultCode of the response.

◆ getAndDownloadMultipart()

commonInterfaces::ResultCode alexaClientSDK::acsdkAssets::common::CurlWrapper::getAndDownloadMultipart ( const std::string &  url,
std::shared_ptr< ResponseSink sink,
const std::weak_ptr< CurlProgressCallbackInterface > &  callbackObj 
)

Executes HTTP GET request which returns a multipart response streams the data in chunks and downloads them to file.

Parameters
urlIN, the URL to execute, must be a https. It should include any query parameters as well.
sinkOUT, object that is used by the multipart parser to read in the data.
callbackObjobject that implements CurlProgressCallbackInterface
Returns
ResultCode of the response.

◆ getHeaders()

HeaderResults alexaClientSDK::acsdkAssets::common::CurlWrapper::getHeaders ( const std::string &  url)

Executes HTTP HEAD request and populates the response.

Parameters
urlIN, the URL to execute, must use https. It should include any query parameters as well.
Returns
the string populated with the HTTP Headers, or an empty string upon failure.

◆ getHeadersAuthorized()

HeaderResults alexaClientSDK::acsdkAssets::common::CurlWrapper::getHeadersAuthorized ( const std::string &  url)

Executes HTTP HEAD request and populates the response. Authorizes to access davs headers

Parameters
urlIN, the URL to execute, must use https. It should include any query parameters as well.
Returns
the string populated with the HTTP Headers, or an empty string upon failure.

◆ getValueFromHeaders()

static std::string alexaClientSDK::acsdkAssets::common::CurlWrapper::getValueFromHeaders ( const std::string &  headers,
const std::string &  key 
)
static

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