-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRequest.h
More file actions
110 lines (95 loc) · 2.92 KB
/
Request.h
File metadata and controls
110 lines (95 loc) · 2.92 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef _MONGOOSE_REQUEST_H
#define _MONGOOSE_REQUEST_H
#include <iostream>
#include <sstream>
#include <vector>
#ifdef ENABLE_REGEX_URL
#include <regex>
#endif
#include <mongoose.h>
#include "UploadFile.h"
#include "Response.h"
using namespace std;
/**
* Request is a wrapper for the clients requests
*/
namespace Mongoose
{
class Request
{
public:
Request(struct mg_connection *connection);
/**
* Sends a given response to the client
*
* @param Response a response for this request
*/
void writeResponse(Response *response);
/**
* Check if the variable given by key is present in GET or POST data
*
* @param string the name of the variable
*
* @return bool true if the param is present, false else
*/
bool hasVariable(string key);
/**
* Get All variable present in GET or POST data
*
* @brief getAllVariable
* @return map<string, string> with all variables
*/
map<string, string> getAllVariable();
/**
* Get the value for a certain variable
*
* @param string the name of the variable
* @param string the fallback value if the variable doesn't exists
*
* @return string the value of the variable if it exists, fallback else
*/
string get(string key, string fallback = "");
/**
* Checks if the given cookie exists
*
* @param string the name of the cookie
*
* @return bool true if the given cookie is set
*/
bool hasCookie(string key);
/**
* Try to get the cookie value
*
* @param string the name of the cookie
* @param string the fallback value
*
* @retun the value of the cookie if it exists, fallback else
*/
string getCookie(string key, string fallback = "");
/**
* Handle uploads to the target directory
*
* @param string the target directory
* @param path the posted file path
*/
void handleUploads();
string getUrl();
string getMethod();
string getData();
#ifdef ENABLE_REGEX_URL
smatch getMatches();
bool match(string pattern);
#endif
bool readVariable(const char *data, string key, string &output);
/**
* Files uploaded in this request
*/
vector<UploadFile> uploadFiles;
protected:
string method;
string url;
string data;
struct mg_connection *connection;
};
}
#endif