@@ -289,26 +289,24 @@ void HTTPConnection::raiseError(uint16_t code, std::string reason) {
289
289
void HTTPConnection::readLine (int lengthLimit) {
290
290
while (_bufferProcessed < _bufferUnusedIdx) {
291
291
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" );
306
301
}
302
+ return ;
303
+ }
304
+ if ( newChar == ' \r ' ) {
305
+ partialTerminationParsed = true ;
307
306
} else {
308
307
_parserLine.text += newChar;
309
- _bufferProcessed += 1 ;
310
308
}
311
-
309
+
312
310
// Check that the max request string size is not exceeded
313
311
if (_parserLine.text .length () > lengthLimit) {
314
312
HTTPS_LOGW (" Header length exceeded. FID=%d" , _socket);
0 commit comments