-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequest.hpp
More file actions
65 lines (54 loc) · 1.62 KB
/
Request.hpp
File metadata and controls
65 lines (54 loc) · 1.62 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
#pragma once
#include <any>
#include <string>
#include <map>
#include "Methods.hpp"
namespace zia::http {
/**
* The Request interface represents the incoming HTTP request
*/
class Request {
public:
/**
* Gets the raw bytes of a request
* @return The string that represents the request
*/
virtual std::string getRaw() = 0;
/**
* Sets the raw bytes of the request.
* This method should only be used by the Core and any module that deciphers the contents of the request.
*/
virtual void setRaw(std::string raw) = 0;
/**
* Parses the request from it's raw bytes.
* This method should at least fill the headers and the url parameters.
*/
virtual void parse() = 0;
/**
* Returns the body of the request, as parsed by any body parsing module used.
* @return The body of the request
*/
virtual std::any body() = 0;
/**
* Gets the value of a header field
* @param field The name of the field to get
* @return The value of the field, an empty string if no such field is found.
*/
virtual std::string getHeader(std::string field) = 0;
/**
* Returns the method of the request
* @return The HTTP::Method object that corresponds to the method for this request
*/
virtual http::Method method() = 0;
/**
* Returns the protocol string for the request, e.g. HTTP/1.1
* @return The protocol string
*/
virtual std::string protocol() = 0;
/**
* The full url of the request, e.g. http://site.tld/page/info?query
* @return The url string
*/
virtual std::string url() = 0;
};
}