AuxPort 0.2
Modules for Audio Software Development
|
This class provides a C++ wrapper for the curl library. More...
#include <AuxCurl.h>
Public Types | |
enum | RequestType { GET , POST } |
Specifies the Type of Request to perform. More... | |
Public Member Functions | |
AuxCurl () | |
Initializes the AuxCurl Object. | |
~AuxCurl () | |
Destructs and cleans up the AuxCurl Object. | |
void | setURL (const std::string &URL) |
Sets the target URL for the Request. | |
void | addHeaders (const std::vector< AuxPort::StringPair > &headers) |
Specify the Headers to be passed in the Request. | |
void | clearHeaders () |
Clears all custom provided headers and sets the CURL default Headers. | |
void | setPostFields (const std::string &postFields) |
Sets the HTTP POST Fields. The POST fields are sent exactly as provided to the function. Also, make sure to set the 'content-type' header corresponding to your postFields. | |
void | setResponseHandler (const std::function< void(const std::string &responseData)> &responseHandler) |
Sets a custom handler to handle the Response Data. | |
bool | sendRequest (const RequestType &type) |
Sends the request to the target URL and executes the response Handler upon completion. | |
std::string | getResponseAsString () |
Returns the Response Data of the last sent Request as a String Object. | |
AuxPort::Extensions::AuxCurl::AuxCurl | ( | ) |
Initializes the AuxCurl Object.
Definition at line 3 of file AuxCurl.cpp.
AuxPort::Extensions::AuxCurl::~AuxCurl | ( | ) |
Destructs and cleans up the AuxCurl Object.
Definition at line 13 of file AuxCurl.cpp.
void AuxPort::Extensions::AuxCurl::addHeaders | ( | const std::vector< AuxPort::StringPair > & | headers | ) |
Specify the Headers to be passed in the Request.
Definition at line 24 of file AuxCurl.cpp.
void AuxPort::Extensions::AuxCurl::clearHeaders | ( | ) |
Clears all custom provided headers and sets the CURL default Headers.
Definition at line 33 of file AuxCurl.cpp.
std::string AuxPort::Extensions::AuxCurl::getResponseAsString | ( | ) |
Returns the Response Data of the last sent Request as a String Object.
Definition at line 77 of file AuxCurl.cpp.
bool AuxPort::Extensions::AuxCurl::sendRequest | ( | const RequestType & | type | ) |
Sends the request to the target URL and executes the response Handler upon completion.
Definition at line 51 of file AuxCurl.cpp.
void AuxPort::Extensions::AuxCurl::setPostFields | ( | const std::string & | postFields | ) |
Sets the HTTP POST Fields. The POST fields are sent exactly as provided to the function. Also, make sure to set the 'content-type' header corresponding to your postFields.
Definition at line 40 of file AuxCurl.cpp.
void AuxPort::Extensions::AuxCurl::setResponseHandler | ( | const std::function< void(const std::string &responseData)> & | responseHandler | ) |
Sets a custom handler to handle the Response Data.
The passed function/lambda will be called after completion of an request and will receive the Response Data as a string argument. You can provide access to local variables using lambda captures. Example Usage:
Definition at line 46 of file AuxCurl.cpp.
void AuxPort::Extensions::AuxCurl::setURL | ( | const std::string & | URL | ) |
Sets the target URL for the Request.
Definition at line 19 of file AuxCurl.cpp.