-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpRequest.h
More file actions
42 lines (35 loc) · 1.2 KB
/
Copy pathHttpRequest.h
File metadata and controls
42 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include "Log.h"
using namespace std;
enum Status{
READ_AGAIN = 0,
OK = 200,
BAD_REQUEST = 400,
NOT_FOUND = 404,
INTERNAL_SERVER_ERROR = 500,
SERVICE_UNAVAILABLE = 503
};
class HttpRequest{
public:
Status parse(string &row_data);
const string getMethod(){ return method; };
const string& getUrl() const { return url; };
const Status getStatus() {return status; };
const map<string,string>& getHeader(){ return header; };
const map<string,string>& getParams(){ return params; };
private:
void resolve_get_params(); //解析GET请求参数
Status status; //请求的结果
string method; //该http请求方法
string url; //请求URL
string version; //http版本
map<string,string> header; //头部字段信息
map<string,string> params; //get请求参数,对post请求无效
string req_body; //post请求体,get请求则为空
};
std::vector<std::string> splitString(std::string srcStr, std::string delimStr,bool repeatedCharIgnored);