Commit 5ee83a24 authored by mr-ti's avatar mr-ti
Browse files

No commit message

No commit message
parent cb88088a
......@@ -11,8 +11,6 @@
//
#include "ddnsshttpcl.h"
#include "cregex.h"
string *DdnssHttpCl::resBuf=NULL;
CUniMutex DdnssHttpCl::mutResBuf;
DdnssHttpCl::DdnssHttpCl()
: CUniObj() {
......@@ -21,7 +19,6 @@ DdnssHttpCl::DdnssHttpCl()
handle=curl_easy_init(); //Initialise la lib cURL
curl_easy_setopt(handle, CURLOPT_USERAGENT, "Mozilla/5.0");
curl_easy_setopt(handle,CURLOPT_WRITEFUNCTION,writeInRepBuf);
curl_easy_setopt(handle,CURLOPT_WRITEDATA,NULL);
//curl_easy_setopt(handle,CURLOPT_TIMEOUT,timeout);
//curl_easy_setopt(handle,CURLOPT_CONNECTTIMEOUT,timeout);
curl_easy_setopt(handle,CURLOPT_SSL_VERIFYPEER,0);
......@@ -49,20 +46,15 @@ void DdnssHttpCl::setHttpUserPwd(const string &login, const string &passwd){
}
bool DdnssHttpCl::get(string &result, const string &url){
bool ret=true;
mutResBuf.lock();
curl_easy_setopt(handle,CURLOPT_CUSTOMREQUEST,"GET"); //Paramètre le type de requête
curl_easy_setopt(handle,CURLOPT_URL,url.c_str());
resBuf=&result;
curl_easy_setopt(handle,CURLOPT_WRITEDATA,&result);
if(curl_easy_perform(handle)!=0)
ret=false;
mutResBuf.unlock();
return ret;
return false;
return true;
}
bool DdnssHttpCl::post(string &result, const string &url){
bool ret=true;
mutResBuf.lock();
string urlTmp,data;
string::size_type n=url.find('?');
if(n!=string::npos){
......@@ -73,16 +65,15 @@ bool DdnssHttpCl::post(string &result, const string &url){
}
curl_easy_setopt(handle,CURLOPT_CUSTOMREQUEST,"POST"); //Paramètre le type de requête
curl_easy_setopt(handle,CURLOPT_POSTFIELDS,data.c_str()); //Enregistre les données de la requête
curl_easy_setopt(handle,CURLOPT_WRITEDATA,&result);
curl_easy_setopt(handle,CURLOPT_URL,urlTmp.c_str());
resBuf=&result;
if(curl_easy_perform(handle)!=0)
ret=false;
mutResBuf.unlock();
return ret;
return false;
return true;
}
size_t DdnssHttpCl::writeInRepBuf(void *ptr, size_t size, size_t nmemb, FILE *out){
resBuf->append((char*)ptr,size*nmemb);
((string*)out)->append((char*)ptr,size*nmemb);
return size*nmemb;
}
......
......@@ -13,7 +13,7 @@
#ifndef DDNSSHTTPCL_H
#define DDNSSHTTPCL_H
#include <curl/curl.h>
#include <unicomctrl/cunimutex.h>
#include <unicomctrl/cuniobj.h>
class DdnssHttpCl : public CUniObj{
public:
......@@ -28,8 +28,6 @@ private:
string publicIpGetAdress;
CURL *handle;
static size_t writeInRepBuf(void *ptr, size_t size, size_t nmemb, FILE *out);
static CUniMutex mutResBuf;
static string *resBuf;
};
#endif
......@@ -32,9 +32,11 @@ public:
string dname;
CUniStringList cmdList;
};
DDnsSSList();
DDnsSSList(CUniConf &cf);
~DDnsSSList();
virtual string className();
private:
list<DName*> dnList;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment