EHS
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
69 ContentType GetContentType() const;
70
74 void AddToHeader(const Str_8& var, const Str_8& value);
75
79 Str_8 GetHeader(const Str_8& var) const;
80
83 Vector<Str_8> GetHeader() const;
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
Definition: Response.h:12
Response(const Response &res)=default
Definition: Vector.h:18
Definition: Anchor.h:6
unsigned int UInt_32
Definition: Types.h:49
ContentType
Definition: Socket.h:35