-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathResponse.h
More file actions
79 lines (67 loc) · 1.79 KB
/
Response.h
File metadata and controls
79 lines (67 loc) · 1.79 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef _MONGOOSE_RESPONSE_H
#define _MONGOOSE_RESPONSE_H
#include <map>
#include <sstream>
#include <iostream>
#define HTTP_OK 200
#define HTTP_NOT_FOUND 404
#define HTTP_FORBIDDEN 403
#define HTTP_SERVER_ERROR 500
using namespace std;
/**
* A response to a request
*/
namespace Mongoose
{
class Response
{
public:
Response();
virtual ~Response();
/**
* Test if the given header is present
*
* @param string the header key
*
* @return bool true if the header is set
*/
virtual bool hasHeader(string key);
/**
* Sets the header
*
* @param key the header key
*
* @param value the header value
*/
virtual void setHeader(string key, string value);
/**
* Get the data of the response, this will contain headers and
* body
*
* @return string the response data
*/
virtual string getData();
/**
* Gets the response body
*
* @return string the response body
*/
virtual string getBody()=0;
/**
* Sets the cookie, note that you can only define one cookie by request
* for now
*
* @param string the key of the cookie
* @param string value the cookie value
*/
virtual void setCookie(string key, string value);
/**
* Sets the response code
*/
virtual void setCode(int code);
protected:
int code;
map<string, string> headers;
};
}
#endif