Skip to content

Commit f11aabc

Browse files
authored
Merge pull request #183 from WEBcodeX1/arduino
Cosmetical, remove comments
2 parents 3d639c2 + 74ac44d commit f11aabc

3 files changed

Lines changed: 11 additions & 18 deletions

File tree

lib/http/httpparser.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ void HTTPParser::appendBuffer(const char* BufferRef, const uint16_t RecvBytes)
3333
if (_POSTWaitContentLength == true && _HTTPRequestBuffer.length() >= _POSTContentLength) {
3434
_RequestProperties.Payload = _HTTPRequestBuffer.substr(0, _POSTContentLength);
3535
_HTTPRequestBuffer.replace(0, _POSTContentLength, "");
36-
//_Requests.push_back(_RequestProperties);
3736
_Requests.emplace(_ReqAddIndex, _RequestProperties);
3837
_ReqAddIndex += 1;
3938
_POSTWaitContentLength = false;
@@ -120,7 +119,6 @@ inline bool HTTPParser::_processRequestProperties(const size_t Index)
120119
_parseGETParameter(_RequestProperties.URL, _RequestProperties.URLParams);
121120

122121
//- add request to requests map
123-
//_Requests.push_back(_RequestProperties);
124122
_Requests.emplace(_ReqAddIndex, _RequestProperties);
125123
_ReqAddIndex += 1;
126124
}
@@ -152,7 +150,6 @@ inline bool HTTPParser::_processRequestProperties(const size_t Index)
152150
_RequestProperties.Payload = _HTTPRequestBuffer.substr(0, _POSTContentLength);
153151
_HTTPRequestBuffer.replace(0, _POSTContentLength, "");
154152
//- add request to requests map
155-
//_Requests.push_back(_RequestProperties);
156153
_Requests.emplace(_ReqAddIndex, _RequestProperties);
157154
_ReqAddIndex += 1;
158155
}
@@ -168,7 +165,6 @@ inline bool HTTPParser::_processRequestProperties(const size_t Index)
168165
_RequestProperties.Payload = NextRequest.substr(0, _POSTContentLength);
169166
NextRequest.replace(0, _POSTContentLength, "");
170167
//- add request to requests map
171-
//_Requests.push_back(_RequestProperties);
172168
_Requests.emplace(_ReqAddIndex, _RequestProperties);
173169
_ReqAddIndex += 1;
174170
}

lib/http/httpparser.hpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,31 +102,28 @@ class StringHelper {
102102
size_t FindPos = 0;
103103
size_t FindPosLast = 0;
104104
string Token;
105-
// Guard: if StartPos is smaller than the delimiter length, a plain
106-
// subtraction would underflow (size_t is unsigned). Just return the
107-
// substring up to StartPos as the sole token.
105+
108106
if (StartPos < Delimiter.length()) {
109107
ResultRef.push_back(String.substr(0, StartPos));
110108
return;
111109
}
110+
112111
StartPos -= Delimiter.length();
112+
113113
while ((FindPos = String.rfind(Delimiter, StartPos)) != String.npos) {
114+
114115
Token = String.substr(FindPos+Delimiter.length(), (StartPos-FindPos));
115116
ResultRef.push_back(Token);
116-
// Guard: if the delimiter sits at the very start (or closer to the
117-
// start than its own length), another subtraction would underflow.
118-
// Record the position and break; the final substr(0, FindPosLast)
119-
// below will correctly capture the token before this delimiter.
117+
120118
if (FindPos < Delimiter.length()) {
121119
FindPosLast = FindPos;
122120
break;
123121
}
122+
124123
StartPos = FindPos - Delimiter.length();
125124
FindPosLast = FindPos;
126125
}
127-
// Push the leading token: the substring from 0 up to the position of
128-
// the last delimiter found (FindPosLast), which is 0 when no delimiter
129-
// was found (producing an empty string as the sentinel).
126+
130127
Token = String.substr(0, FindPosLast);
131128
ResultRef.push_back(Token);
132129
}

test/unit/http-parser/test-parser-requests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,9 @@ BOOST_AUTO_TEST_CASE( test_urlparamsmap2_json )
536536
}
537537

538538

539-
// =========================================================================
539+
// ======================================================================
540540
// Category 1: Malformed headers (missing space or disallowed characters)
541-
// =========================================================================
541+
// ======================================================================
542542

543543
BOOST_AUTO_TEST_CASE( test_malformed_header_missing_space_after_colon )
544544
{
@@ -986,9 +986,9 @@ BOOST_AUTO_TEST_CASE( test_binary_file_kmod_byte_by_byte )
986986
}
987987

988988

989-
// =========================================================================
989+
// ===========================================================================
990990
// Category 5: Requests designed to stress-test / potentially crash the parser
991-
// =========================================================================
991+
// ===========================================================================
992992

993993
BOOST_AUTO_TEST_CASE( test_crash_request_line_method_only )
994994
{

0 commit comments

Comments
 (0)