本文整理汇总了C++中HttpConnection::setSSLVerifyServer方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpConnection::setSSLVerifyServer方法的具体用法?C++ HttpConnection::setSSLVerifyServer怎么用?C++ HttpConnection::setSSLVerifyServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpConnection
的用法示例。
在下文中一共展示了HttpConnection::setSSLVerifyServer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getToken
/*
Returns the token for wassup based authentication or an empty string if errors occur
Parameters:
username: as inserted by the user
password: as inserted by the user
err: output flag to check for errors
*/
std::string WassupTokenRequestManager::getToken(std::string username, std::string password, bool *err, int* requestCode)
{
std::string token = "";
*err = false;
*requestCode = HTTP_OK;
//request token over http
LOG.debug("Getting wassup token");
StringOutputStream response;
HttpConnection *httpConnection = NULL;
URL requestUrl;
std::string formattedURL(_wassupURI);
std::stringstream ss;
std::string xmlResponse;
//URL encode usr and pwd
const char * usernameEncoded = URL::urlEncode(username.c_str());
const char * passwordEncoded = URL::urlEncode(password.c_str());
ss << _wassupURI << "?" << _wassupUsrParam << usernameEncoded << "&" << _wassupPwdParam << passwordEncoded << "&" << _wassupAdditionalParam;
formattedURL = ss.str();
requestUrl.setURL(formattedURL.c_str());
httpConnection = new HttpConnection(_userAgent);
httpConnection->setSSLVerifyServer(verifyServerSSL);
if (httpConnection->open(requestUrl, HttpConnection::MethodGet, false)!= 0) {
LOG.error("%s: error opening connection", __FUNCTION__);
*err = true;
*requestCode = -1;
delete httpConnection;
return "";
} else {
int requestStatus = HTTP_OK;
if ((requestStatus = httpConnection->request(NULL, response, false)) != HTTP_OK) {
LOG.error("%s: error sending Wassup access token request", __FUNCTION__);
*err = true;
if ((requestStatus == HttpConnection::StatusNetworkError) ||
(requestStatus == HttpConnection::StatusReadingError) ||
(requestStatus == HttpConnection::StatusTimeoutError) ||
(requestStatus == HttpConnection::StatusWritingError)) {
*requestCode = -1;
} else {
*requestCode = requestStatus;
}
httpConnection->close();
delete httpConnection;
return "";
} else {
xmlResponse.assign(response.getString().c_str());
//LOG.debug("Wassup access token request response received: %s", xmlResponse.c_str());
}
}
httpConnection->close();
delete httpConnection;
//parse response to extract token
unsigned int startPos = 0;
unsigned int endPos = 0;
bool found = false;
while(!found & !*err)
{
if(XMLProcessor::getElementAttributes(xmlResponse.c_str(), "ident", &startPos, &endPos)==NULL)
{
LOG.error("%s: error parsing XML response", __FUNCTION__);
*err = true;
}
else
{
std::string attributeName = xmlResponse.substr(startPos+6, 6);
int tokenStartIndex = startPos + 21;
int tokenEndIndex = endPos - 3;
int tokenLenght = tokenEndIndex - tokenStartIndex + 1;
if (attributeName=="cooses") {
token = xmlResponse.substr(tokenStartIndex, tokenLenght);
found = true;
}
else//try next tag
{
xmlResponse = xmlResponse.substr(endPos+1);
}
}
}
//.........这里部分代码省略.........