#include <CurlEasyHandleWrapper.h>
Class to allocate and configure a curl easy handle
◆ CurlCallback
Callbacks to libcurl typically follow the below pattern. size_t callback(char* buffer, size_t blockSize, size_t numBlocks, void* userData)
- Parameters
-
buffer | A pointer to the data buffer to either read or write to |
blockSize | The size of a "block" of data (ala fwrite) |
numBlocks | The number of "blocks" to read or write |
userData | Some user data passed in with CURLOPT_XDATA (where X = READ, WRITE, or HEADER) |
◆ CurlDebugCallback
Debug Callbacks to libcurl typically follow the below pattern. size_t callback(CURL* handle, curl_infotype infoType, char *buffer, size_t blockSize, void *userData)
- Parameters
-
handle | The CURL handle |
handle | The CURL info type |
buffer | A pointer to the data buffer to either read or write to |
blockSize | The size of a "block" of data (ala fwrite) |
userData | Some user data passed in with CURLOPT_DEBUGDATA |
◆ TransferType
Definitions for HTTP action types
Enumerator |
---|
kGET | HTTP GET.
|
kPOST | HTTP POST.
|
kPUT | HTTP PUT.
|
◆ CurlEasyHandleWrapper()
alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::CurlEasyHandleWrapper |
( |
std::string |
id = "" | ) |
|
Default constructor, optionally passing in an explicit Id.
- Parameters
-
id | name to use to identify this handle. If none provided, an automatically generated one will be assigned. |
◆ ~CurlEasyHandleWrapper()
alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::~CurlEasyHandleWrapper |
( |
| ) |
|
◆ addHTTPHeader()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::addHTTPHeader |
( |
const std::string & |
header | ) |
|
◆ addPostHeader()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::addPostHeader |
( |
const std::string & |
header | ) |
|
◆ curlOptionsSetter()
◆ getCurlHandle()
CURL* alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::getCurlHandle |
( |
| ) |
|
Used to get the underlying CURL easy handle. The handle returned may be a nullptr
- Returns
- The associated libcurl easy handle
◆ getEffectiveUrl()
std::string alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::getEffectiveUrl |
( |
| ) |
|
Get the effective URL.
- Note
- In cases where CURLOPT_FOLLOWLOCATION is used, CURL follows the url it receives in the location header of the response until it reaches a URL with no location header. This last used url is the effective URL.
- Returns
- The effective URL string.
◆ getHTTPResponseCode()
long alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::getHTTPResponseCode |
( |
| ) |
|
Get the HTTP response code.
- Returns
- The HTTP response code.
◆ getId()
std::string alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::getId |
( |
| ) |
const |
Get the ID for this handle.
- Returns
- The ID for this handle.
◆ getInterfaceName()
static std::string alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::getInterfaceName |
( |
| ) |
|
|
static |
Static function to get the network interface.
- Returns
- the current network interface, otherwise an empty string.
◆ isValid()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::isValid |
( |
| ) |
|
Used to check if curl is correctly initialized
- Returns
- true if curl handler is valid
◆ pause()
CURLcode alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::pause |
( |
int |
mask | ) |
|
◆ perform()
CURLcode alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::perform |
( |
| ) |
|
Perform whatever has been setup in the handle.
- Returns
- The CURL response code.
◆ reset()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::reset |
( |
std::string |
id = "" | ) |
|
Resets an allocated easy handle for re-use in another transfer Calls curl_easy_reset on the curl easy handle Frees and sets the following members to nullptr:
-
HTTP headers
-
POST headers
-
CURL post form
- Parameters
-
id | name to use to identify this handle. If none provided, an automatically generated one will be assigned. |
- Returns
- Whether the reset was successful
◆ setConnectionTimeout()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::setConnectionTimeout |
( |
const std::chrono::seconds |
timeoutSeconds | ) |
|
Sets how long the stream should take, in seconds, to establish a connection. If not set explicitly there is no timeout.
- Parameters
-
timeoutSeconds | The amount of time, in seconds, establishing a connection should take. Set to 0 to disable a timeout. |
- Returns
- Whether setting the timeout was successful
◆ setHeaderCallback()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::setHeaderCallback |
( |
CurlCallback |
callback, |
|
|
void * |
userData |
|
) |
| |
Sets the callback to call when libcurl has HTTP header data available NOTE: Each header line is provided individually
- Parameters
-
callback | A function pointer to the callback |
userData | Any data to be passed to the callback |
- Returns
- Whether the addition was successful
◆ setInterfaceName()
static void alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::setInterfaceName |
( |
const std::string & |
interfaceName | ) |
|
|
static |
Static function to set the network interface to be used for the curl connection.
Network interface provided will be used in preference over the value in provided in config. Set emtpy string to reset to default.
- Note
- The network interace set shall applied only to newly instantiated
CurlEasyHandleWrapper
objects.
- Parameters
-
value | The interface name as defined in CURLOPT_INTERFACE. |
◆ setPostData()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::setPostData |
( |
const std::string & |
data | ) |
|
Sets the data to be sent in the next POST operation.
- Parameters
-
data | String buffer to the full data to send in a HTTP POST operation. |
- Returns
- Whether the operation was successful.
◆ setReadCallback()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::setReadCallback |
( |
CurlCallback |
callback, |
|
|
void * |
userData |
|
) |
| |
Sets the callback to call when libcurl requires data to POST
- Parameters
-
callback | A function pointer to the callback |
userData | Any data to be passed to the callback |
- Returns
- Whether the addition was successful
◆ setTransferTimeout()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::setTransferTimeout |
( |
const long |
timeoutSeconds | ) |
|
Sets a timeout, in seconds, for how long the stream transfer is allowed to take. If not set explicitly, there will be no timeout.
- Parameters
-
timeoutSeconds | The amount of time in seconds the stream can take. Set to 0 to disable a timeout. |
- Returns
- Whether setting the timeout was succesful
◆ setTransferType()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::setTransferType |
( |
TransferType |
type | ) |
|
Sets the HTTP action to perform.
- Parameters
-
type | The action to perform |
- Returns
- true if the setting was successful
◆ setURL()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::setURL |
( |
const std::string & |
url | ) |
|
Set the request URL. No validation is done at this stage
- Parameters
-
- Returns
- true if setting was successful
◆ setWriteCallback()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::setWriteCallback |
( |
CurlCallback |
callback, |
|
|
void * |
userData |
|
) |
| |
Sets the callback to call when libcurl has response data to consume
- Parameters
-
callback | A function pointer to the callback |
userData | Any data to be passed to the callback |
- Returns
- Whether the addition was successful
◆ urlEncode()
std::string alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::urlEncode |
( |
const std::string & |
in | ) |
const |
URL encode a string.
- Parameters
-
- Returns
- The encoded string.
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