60 lines
1.1 KiB
C
60 lines
1.1 KiB
C
|
|
/**
|
|||
|
|
* http
|
|||
|
|
* */
|
|||
|
|
|
|||
|
|
#ifndef MYHTTP_H_
|
|||
|
|
#define MYHTTP_H_
|
|||
|
|
|
|||
|
|
#include <sstream>
|
|||
|
|
#include <sys/socket.h>
|
|||
|
|
#include <netinet/in.h>
|
|||
|
|
#include <netinet/tcp.h>
|
|||
|
|
#include <netdb.h>
|
|||
|
|
#include <cstring>
|
|||
|
|
#include <unistd.h>
|
|||
|
|
#include <mutex>
|
|||
|
|
|
|||
|
|
namespace ai_matrix
|
|||
|
|
{
|
|||
|
|
class MyHttp final
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
static MyHttp *getins();
|
|||
|
|
|
|||
|
|
std::string socketHttp(std::string host, std::string request);
|
|||
|
|
|
|||
|
|
std::string postData(std::string host, std::string path, std::string post_content);
|
|||
|
|
|
|||
|
|
std::string getData(std::string host, std::string path, std::string get_content);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
|
|||
|
|
MyHttp() = default;
|
|||
|
|
MyHttp(const MyHttp &) = delete;
|
|||
|
|
MyHttp(MyHttp &&) = delete;
|
|||
|
|
MyHttp &operator=(const MyHttp &) = delete;
|
|||
|
|
MyHttp &operator=(MyHttp &&) = delete;
|
|||
|
|
~MyHttp() = default;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ƕ<EFBFBD><C7B6><EFBFBD>࣬<EFBFBD><E0A3AC><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ڴ棬<DAB4><E6A3AC><EFBFBD><EFBFBD>ϵͳ<CFB5>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ڴ<EFBFBD>й¶
|
|||
|
|
class GarbageCollector
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
~GarbageCollector()
|
|||
|
|
{
|
|||
|
|
if (MyHttp::ins)
|
|||
|
|
{
|
|||
|
|
delete MyHttp::ins;
|
|||
|
|
MyHttp::ins = nullptr;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
static GarbageCollector gc;
|
|||
|
|
static MyHttp *ins;
|
|||
|
|
static std::mutex mx; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD>̰߳<DFB3>ȫ
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endif
|