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 std::string CurlClient::getErrorBuffer () const
const int CurlClient::getErrorCode () const
int CurlClient::getHttpStatus ()
const std::string CurlClient::callGet ()
const std::string CurlClient::callPost (const std::string &postData)
void CurlClient::uploadToFTP (std::stringstream &in)
const std::string CurlClient::downloadFromFTP (void)
std::string CurlClient::escapeUrl (const std::string &url)
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 (  )  [inherited]

Make 'get' request

Returns:
server's respose
const std::string CurlClient::callPost ( const std::string &  postData  )  [inherited]

Make 'post' request

Returns:
server's response
void CurlClient::clearHeaders (  )  [inline, inherited]

Clear Header

const std::string CurlClient::downloadFromFTP ( void   )  [inherited]

Download file from FTP server

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

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 [inline, inherited]
Returns:
error string
const int CurlClient::getErrorCode (  )  const [inline, inherited]
Returns:
error code
const std::string CurlClient::getFullErrorMessage ( void   )  const [inherited]

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 (  )  [inline, inherited]
Returns:
HTTP status code
std::string CurlClient::getResultHeader (  )  [inline, inherited]

Get Header

Returns:
header
void CurlClient::setClientCert ( const std::string &  cert  )  [inline, inherited]

Set Client Cert

Parameters:
cert - certificate
void CurlClient::setClientCertType ( const std::string &  type  )  [inline, inherited]

Set Client Cert Type

Parameters:
type - type of certificate
void CurlClient::setClientKey ( const std::string &  key  )  [inline, inherited]

Set Client Key

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

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  )  [inline, inherited]

Set Content Type

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

Set Header

Parameters:
Header of the request
void CurlClient::setHttpAuth ( const std::string &  s_username,
const std::string &  s_password 
) [inline, inherited]

Set login and password for HTTP(S) authorization

Parameters:
s_username string - username.
s_password string - password.
void CurlClient::setTimeOut ( int  iTimeOut  )  [inline, inherited]

Set Time out

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

Set using SSLv3 instead of TLSv1

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

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  )  [inherited]

Upload file to FTP server

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

Generated on 3 Jun 2010 for DomainPlug-insDocumentation by  doxygen 1.6.1