Skip to content

Commit bdcc34e

Browse files
cdelerpgjones
authored andcommitted
Fixed PR remarks
- changed blank_line_delimiter_regex - changed maybe_extract_lines start processing
1 parent fbdf194 commit bdcc34e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

h11/_receivebuffer.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# processed a whole event, which could in theory be slightly more efficient
4242
# than the internal bytearray support.)
4343

44-
blank_line_delimiter_regex = re.compile(b"\n\r?\n", re.MULTILINE)
44+
blank_line_delimiter_regex = re.compile(b"(\r\n\r\n|\n\n)", re.MULTILINE)
4545
line_delimiter_regex = re.compile(b"\r?\n", re.MULTILINE)
4646

4747

@@ -126,12 +126,14 @@ def _get_fields_delimiter(self, data, lines_delimiter_regex):
126126
# HTTP/1.1 has a number of constructs where you keep reading lines until
127127
# you see a blank one. This does that, and then returns the lines.
128128
def maybe_extract_lines(self):
129-
start_chunk = self._data[self._start : self._start + 2]
130-
if start_chunk in [b"\r\n", b"\n"]:
131-
self._start += len(start_chunk)
129+
if self._data[self._start : self._start + 2] == b"\r\n":
130+
self._start += 2
131+
return []
132+
elif self._data[self._start : self._start + 1] == b"\n":
133+
self._start += 1
132134
return []
133135
else:
134-
data = self.maybe_extract_until_next(blank_line_delimiter_regex, 3)
136+
data = self.maybe_extract_until_next(blank_line_delimiter_regex, 4)
135137
if data is None:
136138
return None
137139

0 commit comments

Comments
 (0)