DomainPlug-insDocumentation
Functions
Curl Client Lib

Functions

void CurlClient::setTimeOut (int iTimeOut)
void CurlClient::setConnectTimeOut (int iConnectTimeOut)
void CurlClient::setContentType (const std::string &sContentType)
void CurlClient::setHeader (const std::string &sHeader)
void CurlClient::setUseSSLv3 ()
void CurlClient::setClientCert (const std::string &cert)
void CurlClient::setClientCertType (const std::string &type)
void CurlClient::setClientKey (const std::string &key)
void CurlClient::setClientKeyType (const std::string &type)
void CurlClient::setHttpAuth (const std::string &s_username, const std::string &s_password)
void CurlClient::clearHeaders ()
std::string CurlClient::getResultHeader () const
const std::string CurlClient::getErrorBuffer () const
int CurlClient::getErrorCode () const
int CurlClient::getHttpStatus () const
const std::string CurlClient::callGet ()
const std::string CurlClient::callPost (const std::string &postData)
void CurlClient::uploadToFTP (std::stringstream &in)
const std::string CurlClient::callHttpPost (const CurlForm &data)
const std::string CurlClient::downloadFromFTP (void)
static std::string CurlClient::escapeUrl (const std::string &url)
static std::string CurlClient::unescapeUrl (const std::string &url)
const std::string CurlClient::getFullErrorMessage (void) const

Detailed Description

Example1. Post Request.

 #include "curlclient.h"
 #include <iostream>

 using namespace std;

 void main(void) {
   CurlClient tr;

   tr.setTimeOut(60);
   tr.setConnectTimeOut(10);

   tr.setUrl("<url_for_post_request>");
   tr.setHeader("My-Client-Type: <some type>");
   string res = tr.callPost("name1=value1&name2=value2");
   cout << "Response:" << res << endl;
 }

Example2. Get Request.

 #include "curlclient.h"
 #include <iostream>

 using namespace std;
 void main(void) {
 CurlClient tr;
 tr.setTimeOut(60);
 tr.setConnectTimeOut(10);

 tr.setUrl("<url_for_get_request>");
 tr.setHeader("My-Client-Type: test data hessed in header");

 string res = tr.callGet();
 cout << "Response:" << res << endl;
 }

Function Documentation

const std::string CurlClient::callGet ( )

Make 'get' request

Returns:
server's respose
const std::string CurlClient::callHttpPost ( const CurlForm data)

Upload file to HTTP server, aka RFC2388-style posts

const std::string CurlClient::callPost ( const std::string &  postData)

Make 'post' request

Returns:
server's response
void CurlClient::clearHeaders ( )

Clear Header

const std::string CurlClient::downloadFromFTP ( void  )

Download file from FTP server

Returns:
server's response (file contents)
std::string CurlClient::escapeUrl ( const std::string &  url) [static]

Escape URL This function will convert the given input string to an URL encoded string and return that as a new allocated string. All input characters that are not a-z, A-Z or 0-9 will be converted to their "URL escaped" version (NN where NN is a two-digit hexadecimal number).

const std::string CurlClient::getErrorBuffer ( ) const
Returns:
error string
int CurlClient::getErrorCode ( ) const
Returns:
error code
const std::string CurlClient::getFullErrorMessage ( void  ) const

This function returns message with full error description Error message contains error code and error message

Parameters:
none
Returns:
none
See also:
CurlClient::checkResultThrow
int CurlClient::getHttpStatus ( ) const
Returns:
HTTP status code
std::string CurlClient::getResultHeader ( ) const

Get Header

Returns:
header
void CurlClient::setClientCert ( const std::string &  cert)

Set Client Cert

Parameters:
cert- certificate
void CurlClient::setClientCertType ( const std::string &  type)

Set Client Cert Type

Parameters:
type- type of certificate
void CurlClient::setClientKey ( const std::string &  key)

Set Client Key

Parameters:
keystring should be the file name of your private key.
void CurlClient::setClientKeyType ( const std::string &  type)
Parameters:
typeis a string, that should be the format of your private key. Supported formats are "PEM", "DER" and "ENG".
void CurlClient::setConnectTimeOut ( int  iConnectTimeOut)

Set Connection Time out

Parameters:
iConnectTimeOut- seconds that curl client will wait server's response on connection request
void CurlClient::setContentType ( const std::string &  sContentType)

Set Content Type

Parameters:
sContentType- string (e.g. "text/xml")
void CurlClient::setHeader ( const std::string &  sHeader)

Set Header

Parameters:
Headerof the request
void CurlClient::setHttpAuth ( const std::string &  s_username,
const std::string &  s_password 
)

Set login and password for HTTP(S) authorization

Parameters:
s_usernamestring - username.
s_passwordstring - password.
void CurlClient::setTimeOut ( int  iTimeOut)

Set Time out

Parameters:
iTimeOut- seconds that curl client will wait server's response on not connection request
void CurlClient::setUseSSLv3 ( )

Set using SSLv3 instead of TLSv1

std::string CurlClient::unescapeUrl ( const std::string &  url) [static]

This function will convert the given URL encoded input string to a "plain string" and return that as a new allocated string. All input characters that are URL encoded (XX where XX is a two-digit hexadecimal number) will be converted to their plain text versions.

Parameters:
url
Returns:
unescaped url
See also:
CurlClient::escapeUrl
void CurlClient::uploadToFTP ( std::stringstream &  in)

Upload file to FTP server

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines