@@ -290,26 +290,26 @@ 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
+ }
299
+ else {
300
+ // Line has not been terminated by \r\n
301
+ HTTPS_LOGW (" Line without \\ r\\ n (got only \\ r). FID=%d" , _socket);
302
+ raiseError (400 , " Bad Request" );
307
303
}
308
- } else {
304
+ return ;
305
+ }
306
+ if ( newChar == ' \r ' ) {
307
+ partialTerminationParsed = true ;
308
+ }
309
+ else {
309
310
_parserLine.text += newChar;
310
- _bufferProcessed += 1 ;
311
311
}
312
-
312
+
313
313
// Check that the max request string size is not exceeded
314
314
if (_parserLine.text .length () > lengthLimit) {
315
315
HTTPS_LOGW (" Header length exceeded. FID=%d" , _socket);
0 commit comments