-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpResponse.h
More file actions
43 lines (34 loc) · 1 KB
/
Copy pathHttpResponse.h
File metadata and controls
43 lines (34 loc) · 1 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
43
//
// Created by hrkkk on 2024/2/3.
//
#ifndef WEBSERVER_HTTPRESPONSE_H
#define WEBSERVER_HTTPRESPONSE_H
#include <vector>
#include <string>
#include <unordered_map>
#define OK 200
#define CREATED 201
#define NO_CONTENT 204
#define BAD_REQUEST 400
#define NOT_FOUND 404
#define FORBIDDEN 403
#define INTERNAL_SERVER_ERROR 500
#define OPTIONS 1000
#define WEB_ROOT "/tmp/WebServer/resource"
#define CRLF "\r\n"
#define HTTP_VERSION "HTTP/1.0"
class HttpResponse {
public:
HttpResponse(): m_statusCode(OK), m_blankLine(CRLF), m_fd(-1), m_size(0) { }
// HTTP请求内容
std::string m_statusLine; // 响应行
std::vector<std::string> m_responseHeader; // 响应头
std::string m_blankLine; // 空行
std::string m_responseBody; // 响应正文
std::unordered_map<std::string, std::string> m_headerMap;
int m_statusCode;
int m_fd;
int m_size;
std::string m_suffix;
};
#endif //WEBSERVER_HTTPRESPONSE_H