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