EHS
Loading...
Searching...
No Matches
Response.h
Go to the documentation of this file.
1#pragma once
2
3#include "ehs/EHS.h"
4#include "ehs/Vector.h"
5#include "ehs/Str.h"
6#include "ehs/json/Json.h"
7#include "Socket.h"
8
9namespace ehs
10{
11 class EHS_LIB_IO Response
12 {
13 private:
14 UInt_32 code;
15 Str_8 server;
16 ContentType cType;
17 Vector<Str_8> header;
18 Str_8 body;
19
20 public:
22 Response();
23
27 Response(const UInt_32 code, const Str_8& server);
28
32 Response(const char* data, const UInt_64 size);
33
36 Response(const Str_8& data);
37
40 Response(const Response& res) = default;
41
45 Response& operator=(const Response& res);
46
49 void SetCode(const UInt_32 code);
50
53 UInt_32 GetCode() const;
54
57 void SetServer(const Str_8& server);
58
61 Str_8 GetServer() const;
62
65 void SetContentType(const ContentType cType);
66
70
74 void AddToHeader(const Str_8& var, const Str_8& value);
75
79 Str_8 GetHeader(const Str_8& var) const;
80
84
88 void AddToBody(const Str_8& var, const Str_8& value);
89
92 void AddToBody(const Str_8& data);
93
96 void SetBody(const Str_8& body);
97
101 Str_8 GetVar(const Str_8& var) const;
102
105 Str_8 GetBody() const;
106
109 Json GetJson() const;
110
113 Str_8 FormResult() const;
114
115 bool IsValid() const;
116
117 private:
118 static Str_8 CodeToStr(const UInt_32 code);
119
120 static Str_8 ContentTypeToStr(const ContentType cType);
121
122 static ContentType StrToContentType(const Str_8& value);
123
124 void ReadData(const Str_8& data);
125
126 };
127}
Definition Json.h:16
void SetBody(const Str_8 &body)
Definition Response.cpp:123
void SetContentType(const ContentType cType)
Definition Response.cpp:61
Str_8 GetBody() const
Definition Response.cpp:146
Response(const Response &res)=default
void AddToHeader(const Str_8 &var, const Str_8 &value)
Definition Response.cpp:71
void SetServer(const Str_8 &server)
Definition Response.cpp:51
Str_8 GetServer() const
Definition Response.cpp:56
void AddToBody(const Str_8 &var, const Str_8 &value)
Definition Response.cpp:96
bool IsValid() const
Definition Response.cpp:177
Str_8 GetVar(const Str_8 &var) const
Definition Response.cpp:128
void SetCode(const UInt_32 code)
Definition Response.cpp:41
ContentType GetContentType() const
Definition Response.cpp:66
Response & operator=(const Response &res)
Definition Response.cpp:27
Json GetJson() const
Definition Response.cpp:151
Response()
Default member initialization.
Definition Response.cpp:22
Str_8 GetHeader(const Str_8 &var) const
Definition Response.cpp:76
Str_8 FormResult() const
Definition Response.cpp:156
UInt_32 GetCode() const
Definition Response.cpp:46
Definition Vector.h:18
Definition Anchor.h:6
unsigned int UInt_32
Definition Types.h:49
ContentType
Definition Socket.h:35
Str< Char_8, UInt_64 > Str_8
Definition Str.h:1902