restclient-cpp
C++ client for making HTTP/REST requests
Classes | Public Member Functions | List of all members
RestClient::Connection Class Reference

Connection object for advanced usage. More...

#include <connection.h>

Classes

struct  Info
 holds some diagnostics information about the connection object it came from More...
 
struct  RequestInfo
 holds some diagnostics information about a request More...
 

Public Member Functions

 Connection (const std::string &baseUrl)
 constructor for the Connection object More...
 
void SetBasicAuth (const std::string &username, const std::string &password)
 set username and password for basic auth More...
 
void SetTimeout (int seconds)
 set timeout for connection More...
 
void FollowRedirects (bool follow)
 configure whether to follow redirects on this connection More...
 
void SetUserAgent (const std::string &userAgent)
 set custom user agent for connection. This gets prepended to the default restclient-cpp/RESTCLIENT_VERSION string More...
 
void SetCAInfoFilePath (const std::string &caInfoFilePath)
 set custom Certificate Authority (CA) path More...
 
void SetCertPath (const std::string &cert)
 
void SetCertType (const std::string &type)
 
void SetKeyPath (const std::string &keyPath)
 
std::string GetUserAgent ()
 get the user agent to add to the request More...
 
RestClient::Connection::Info GetInfo ()
 get diagnostic information about the connection object More...
 
void SetHeaders (RestClient::HeaderFields headers)
 set the custom headers map. This will replace the currently configured headers with the provided ones. If you want to add additional headers, use AppendHeader() More...
 
RestClient::HeaderFields GetHeaders ()
 get all custom headers set on the connection More...
 
void AppendHeader (const std::string &key, const std::string &value)
 append a header to the internal map More...
 
RestClient::Response get (const std::string &uri)
 HTTP GET method. More...
 
RestClient::Response post (const std::string &uri, const std::string &data)
 HTTP POST method. More...
 
RestClient::Response put (const std::string &uri, const std::string &data)
 HTTP PUT method. More...
 
RestClient::Response del (const std::string &uri)
 HTTP DELETE method. More...
 
RestClient::Response head (const std::string &uri)
 HTTP HEAD method. More...
 

Detailed Description

Connection object for advanced usage.

Constructor & Destructor Documentation

RestClient::Connection::Connection ( const std::string &  baseUrl)
explicit

constructor for the Connection object

Parameters
baseUrl- base URL for the connection to use

Member Function Documentation

void RestClient::Connection::AppendHeader ( const std::string &  key,
const std::string &  value 
)

append a header to the internal map

Parameters
keyfor the header field
valuefor the header field
RestClient::Response RestClient::Connection::del ( const std::string &  url)

HTTP DELETE method.

Parameters
urlto query
Returns
response struct

we want HTTP DELETE

set HTTP DELETE METHOD

void RestClient::Connection::FollowRedirects ( bool  follow)

configure whether to follow redirects on this connection

Parameters
follow- boolean whether to follow redirects
RestClient::Response RestClient::Connection::get ( const std::string &  url)

HTTP GET method.

Parameters
urlto query
Returns
response struct
RestClient::HeaderFields RestClient::Connection::GetHeaders ( )

get all custom headers set on the connection

Returns
a RestClient::HeaderFields map containing the custom headers
RestClient::Connection::Info RestClient::Connection::GetInfo ( )

get diagnostic information about the connection object

Returns
RestClient::Connection::Info struct
std::string RestClient::Connection::GetUserAgent ( )

get the user agent to add to the request

Returns
user agent as std::string
RestClient::Response RestClient::Connection::head ( const std::string &  url)

HTTP HEAD method.

Parameters
urlto query
Returns
response struct

we want HTTP HEAD

set HTTP HEAD METHOD

RestClient::Response RestClient::Connection::post ( const std::string &  url,
const std::string &  data 
)

HTTP POST method.

Parameters
urlto query
dataHTTP POST body
Returns
response struct

Now specify we want to POST data

set post fields

RestClient::Response RestClient::Connection::put ( const std::string &  url,
const std::string &  data 
)

HTTP PUT method.

Parameters
urlto query
dataHTTP PUT body
Returns
response struct

initialize upload object

Now specify we want to PUT data

set read callback function

set data object to pass to callback function

set data size

void RestClient::Connection::SetBasicAuth ( const std::string &  username,
const std::string &  password 
)

set username and password for basic auth

Parameters
username
password
void RestClient::Connection::SetCAInfoFilePath ( const std::string &  caInfoFilePath)

set custom Certificate Authority (CA) path

Parameters
caInfoFilePath- The path to a file holding the certificates used to verify the peer with. See CURLOPT_CAINFO
void RestClient::Connection::SetHeaders ( RestClient::HeaderFields  headers)

set the custom headers map. This will replace the currently configured headers with the provided ones. If you want to add additional headers, use AppendHeader()

Parameters
headersto set
void RestClient::Connection::SetTimeout ( int  seconds)

set timeout for connection

Parameters
seconds- timeout in seconds
void RestClient::Connection::SetUserAgent ( const std::string &  userAgent)

set custom user agent for connection. This gets prepended to the default restclient-cpp/RESTCLIENT_VERSION string

Parameters
userAgent- custom userAgent prefix

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