@@ -290,26 +290,24 @@ void HTTPConnection::raiseError(uint16_t code, std::string reason) {
290
290
void HTTPConnection::readLine (int lengthLimit) {
291
291
while (_bufferProcessed < _bufferUnusedIdx) {
292
292
char newChar = _receiveBuffer[_bufferProcessed];
293
-
294
- if ( newChar == ' \r ' ) {
295
- // Look ahead for \n (if not possible, wait for next round
296
- if (_bufferProcessed+1 < _bufferUnusedIdx) {
297
- if (_receiveBuffer[_bufferProcessed+1 ] == ' \n ' ) {
298
- _bufferProcessed += 2 ;
299
- _parserLine.parsingFinished = true ;
300
- return ;
301
- } else {
302
- // Line has not been terminated by \r\n
303
- HTTPS_LOGW (" Line without \\ r\\ n (got only \\ r). FID=%d" , _socket);
304
- raiseError (400 , " Bad Request" );
305
- return ;
306
- }
293
+ _bufferProcessed++;
294
+ if ( partialTerminationParsed ){
295
+ partialTerminationParsed = false ;
296
+ if (newChar == ' \n ' ) {
297
+ _parserLine.parsingFinished = true ;
298
+ } else {
299
+ // Line has not been terminated by \r\n
300
+ HTTPS_LOGW (" Line without \\ r\\ n (got only \\ r). FID=%d" , _socket);
301
+ raiseError (400 , " Bad Request" );
307
302
}
303
+ return ;
304
+ }
305
+ if ( newChar == ' \r ' ) {
306
+ partialTerminationParsed = true ;
308
307
} else {
309
308
_parserLine.text += newChar;
310
- _bufferProcessed += 1 ;
311
309
}
312
-
310
+
313
311
// Check that the max request string size is not exceeded
314
312
if (_parserLine.text .length () > lengthLimit) {
315
313
HTTPS_LOGW (" Header length exceeded. FID=%d" , _socket);
0 commit comments