File tree 2 files changed +17
-15
lines changed
2 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -290,23 +290,24 @@ void HTTPConnection::readLine(int lengthLimit) {
290
290
while (_bufferProcessed < _bufferUnusedIdx) {
291
291
char newChar = _receiveBuffer[_bufferProcessed];
292
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
- }
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" );
306
302
}
303
+ return ;
304
+ }
305
+
306
+ if ( newChar == ' \r ' ){
307
+ partialTerminationParsed = true ;
307
308
} else {
308
309
_parserLine.text += newChar;
309
- _bufferProcessed += 1 ;
310
+
310
311
}
311
312
312
313
// Check that the max request string size is not exceeded
Original file line number Diff line number Diff line change @@ -131,7 +131,8 @@ class HTTPConnection : private ConnectionContext {
131
131
int _bufferProcessed;
132
132
// The index on the receive_buffer that is the first one which is empty at the end.
133
133
int _bufferUnusedIdx;
134
-
134
+ bool partialTerminationParsed = false ;
135
+
135
136
// Socket address, length etc for the connection
136
137
struct sockaddr _sockAddr;
137
138
socklen_t _addrLen;
You can’t perform that action at this time.
0 commit comments