2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "web/http/decoder/Fields.h"
44#include "core/socket/stream/SocketContext.h"
46#ifndef DOXYGEN_SHOULD_SKIP_THIS
48#include "web/http/http_utils.h"
55#define MAX_LINE_LENGTH 8192
71 std::size_t consumed = 0;
88 if (!
line.empty() || ch !=
' ') {
134 if (headerFieldName.empty()) {
137 }
else if ((std::isblank(headerFieldName.back()) != 0) || (std::isblank(headerFieldName.front()) != 0)) {
140 }
else if (value.empty()) {
142 errorReason =
"Value of field \"" + headerFieldName +
"\" empty";
147 if (!
fields.contains(headerFieldName)) {
148 fields.emplace(headerFieldName, value);
150 fields[headerFieldName] +=
"," + value;
154 errorReason =
"Field '" + headerFieldName +
"' not in expected fields";
std::size_t readFromPeer(char *chunk, std::size_t chunklen) const final
std::string getErrorReason()
Fields(core::socket::stream::SocketContext *socketContext, std::set< std::string > fieldsExpected={})
core::socket::stream::SocketContext * socketContext
web::http::CiStringMap< std::string > fields
void splitLine(const std::string &line)
std::size_t maxLineLength
void setFieldsExpected(std::set< std::string > fieldsExpected)
std::set< std::string > fieldsExpected
web::http::CiStringMap< std::string > && getHeader()
std::pair< std::string, std::string > str_split(const std::string &base, char c_middle)
std::string & str_trimm(std::string &text)