-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHttpRequest.h
59 lines (54 loc) · 1.21 KB
/
HttpRequest.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
#ifndef __HTTPREQUEST_H__
#define __HTTPREQUEST_H__
#include <iostream>
#include <muduo/base/copyable.h>
#include <muduo/base/Timestamp.h>
#include <string>
#include <map>
using namespace std;
class HttpRequest:muduo::copyable
{
public:
enum Method
{
INVALID,
GET,
POST,
HEAD,
PUT,
DELETE
};
enum Version
{
UNKNOWN,
HTTP10,
HTTP11
};
HttpRequest();
void setVersion(Version v);
Version getVersion() const;
bool setMethod(const char *start,const char* end);
Method method()const;
const char*methodString()const;
void setPath(const char*start,const char*end);
const string& path()const;
void setQuery(const char* start, const char* end);
const string& query() const;
void setReceiveTime(muduo::Timestamp t);
muduo::Timestamp receiveTime() const;
void addHeader(const char*start,const char*colon,const char*end);
string getHeader(const string& field)const;
const map<string,string>&headers()const;
void swap(HttpRequest& that);
void setBody(const char*start,const char*end);
string getBody()const;
private:
Method method_;
Version version_;
string path_;
string query_;
string body_;
muduo::Timestamp receiveTime_;
std::map<string,string>headers_;
};
#endif