47 lines
806 B
C++
47 lines
806 B
C++
#pragma once
|
|
#ifndef __HttpClient_H_
|
|
#define __HttpClient_H_
|
|
#include "CCSocket.h"
|
|
#include "CCJSONObject.h"
|
|
#include "CCString.h"
|
|
#include <sstream>
|
|
#include <regex>
|
|
#include "map"
|
|
|
|
#define MaxDataSize 2048
|
|
|
|
enum RequestProcessA
|
|
{
|
|
RequestProcessA_First,
|
|
RequestProcessA_Header,
|
|
RequestProcessA_Body,
|
|
};
|
|
|
|
struct CCResponseA
|
|
{
|
|
std::map<CCString, CCString> Headers;
|
|
char Buffer[MaxDataSize] = { 0 };
|
|
CCString Body;
|
|
CCString Method;
|
|
CCString Path;
|
|
CCString Version;
|
|
int StatusCode = 0;
|
|
};
|
|
|
|
class CCHttpClient
|
|
{
|
|
private:
|
|
|
|
public:
|
|
CCHttpClient();
|
|
~CCHttpClient();
|
|
CCResponseA Request(CCString Url,CCString Data,CCString Method);
|
|
private:
|
|
std::map<CCString, CCString> Headers;
|
|
void parseURL(const std::string& url, std::string& scheme, std::string& ip, int& port, std::string& path);
|
|
};
|
|
|
|
|
|
#endif
|
|
|