-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathhttp.h
More file actions
46 lines (36 loc) · 1.19 KB
/
http.h
File metadata and controls
46 lines (36 loc) · 1.19 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
#ifndef HTTP_H
#define HTTP_H
#include <string>
#include "cirbuf.h"
#include "types.h"
#include "exceptions.h"
class HttpRequest
{
public:
struct Data
{
std::string request;
bool upgrade = false;
bool connectionUpgrade = false;
std::optional<std::string> websocketKey;
std::optional<int> websocketVersion;
std::optional<std::string> subprotocol;
std::optional<std::string> xRealIp;
};
HttpRequest(const Data &data);
HttpRequest(BadHttpRequest &&other);
const Data &value();
operator bool() const;
private:
std::optional<BadHttpRequest> e;
Data d;
};
std::string generateWebsocketAcceptString(const std::string &websocketKey);
std::string generateInvalidWebsocketVersionHttpHeaders(const int wantedVersion);
std::string generateBadHttpRequestReponse(const std::string &msg);
std::string generateWebsocketAnswer(const std::string &acceptString, const std::string &subprotocol);
std::string generateRedirect(const std::string &location);
std::optional<HttpRequest> parseHttpHeader(CirBuf &buf);
std::string websocketCloseCodeToString(uint16_t code);
std::string protocolVersionString(ProtocolVersion p);
#endif // HTTP_H