-
Notifications
You must be signed in to change notification settings - Fork 2
/
http_common.h
67 lines (54 loc) · 1.04 KB
/
http_common.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef HTTP_COMMON_H
#define HTTP_COMMON_H
#include <map>
#include <string>
#include <vector>
#include "sub_string.h"
enum class http_request_method
{
OPTIONS,
GET,
HEAD,
POST,
PUT,
DELETE,
TRACE,
CONNECT,
};
enum class http_version
{
HTTP_10,
HTTP_11,
};
struct http_request_line
{
http_request_method method;
sub_string uri;
http_version version;
};
enum class http_status_code : unsigned
{
ok = 200,
not_modified = 304,
bad_request = 400,
internal_server_error = 500,
not_implemented = 501,
};
struct http_status_line
{
http_version version;
http_status_code status_code;
sub_string reason_phrase;
};
struct http_request
{
http_request_line request_line;
std::map<std::string, std::vector<std::string> > headers;
};
struct http_response
{
http_status_line status_line;
std::map<std::string, std::vector<std::string> > headers;
};
char const* status_code_as_string(http_status_code);
#endif