MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / parse

Method parse

Libraries/Http/HttpParser.cpp:60–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58#define crReset(state) state = 0;
59
60SC::Result SC::HttpParser::parse(Span<const char> data, size_t& readBytes, Span<const char>& parsedData)
61{
62 if (state == State::Finished)
63 {
64 return SC::Result(false);
65 }
66 readBytes = 0;
67 if (type == Type::Request)
68 {
69 if (token == Token::HeadersEnd)
70 {
71 if (state == State::Result)
72 {
73 state = State::Finished;
74 return Result(true);
75 }
76 }
77 }
78 else
79 {
80 if (token == Token::Body)
81 {
82 if (state == State::Result)
83 {
84 state = State::Finished;
85 return Result(true);
86 }
87 }
88 }
89
90 if (data.sizeInBytes() == 0)
91 {
92 return SC::Result(false);
93 }
94
95 SC_CO_BEGIN(topLevelCoroutine);
96 if (type == Type::Request)
97 {
98 //------------------------
99 // Parse Method
100 //------------------------
101 globalStart += globalLength;
102 tokenStart = globalStart;
103 tokenLength = 0;
104 globalLength = 0;
105 do
106 {
107 SC_TRY((process<&HttpParser::parseMethod, Token::Method>(data, readBytes, parsedData)));
108 SC_CO_RETURN(topLevelCoroutine, Result(true));
109 } while (state == State::Parsing);
110 //------------------------
111 // Parse URL
112 //------------------------
113 globalStart += globalLength;
114 tokenStart = globalStart;
115 tokenLength = 0;
116 globalLength = 0;
117 matchIndex = 0;

Callers 6

extractSafeFilePathMethod · 0.45
onDataMethod · 0.45
prepareRequestMethod · 0.45
matchMethod · 0.45
formatAllowHeaderMethod · 0.45
writeHeadersFunction · 0.45

Calls 3

ResultClass · 0.50
sizeInBytesMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected