eis/inc/zcus/httpCurl.h

85 lines
2.5 KiB
C
Raw Normal View History

#ifndef __HTTP_CURL_H__
#define __HTTP_CURL_H__
#include <string>
#define CURL_GET 0
#define CURL_POST 1
#define CURL_PUT 2
#define CURL_DELETE 3
class CHttpCurl
{
public:
CHttpCurl(void);
~CHttpCurl(void);
public:
/**
* @brief HTTP POST请求
* @param strUrl ,Url地址
* @param strPost ,json数据包
* @param strResponse ,
* @return Post成功
*/
//int PostWeb(const std::string & strUrl, const std::string & strPost, std::string & strResponse);
int Post(const std::string & strUrl, const std::string & strPost, std::string & strResponse);
/**
strpost strResponse
*/
int STSQueryPost(const std::string & strPost, std::string & strResponse);
/**
strurl a08.test , strpost strResponse
*/
/*
*/
int OTSQueryPost(const std::string & strUrl,const std::string & strPost, std::string & strResponse);
int OTSRecordPost(const std::string & strUrl, const std::string & strPost, std::string & strResponse);
int STSRecordPost(const std::string & strUrl, const std::string & strPost, std::string & strResponse);
/**
* @brief HTTP GET请求
* @param strUrl ,Url地址
* @param strResponse ,
* @return Post成功
*/
int Get(const std::string & strUrl, std::string & strResponse);
/**
* @brief HTTP DELETE请求
* @param strUrl ,Url地址
* @param strResponse ,
* @return Post成功
*/
int Delete(const std::string & strUrl, std::string & strResponse);
/**
* @brief HTTP PUT请求
* @param strUrl ,Url地址
* @param strResponse ,
* @return Post成功
*/
int Put(const std::string & strUrl, const std::string & strPost, std::string & strResponse);
public:
void SetDebug(bool bDebug);
void SetUserName(const std::string & name);
void SetPassword(const std::string & passwd);
private:
int Curl(const int nMethod, const std::string & strUrl, const std::string & strPost, std::string & strResponse);
private:
bool m_bDebug;
std::string m_name;
std::string m_passwd;
std::string basicUrl;
};
#endif