Skip to content

Commit 2dd8da2

Browse files
cdelerpgjones
authored andcommitted
Small rfg (renamed body_and_headers_delimiter_regex -> blank_line_delimiter_regex) and slightly updated docs
1 parent 7370645 commit 2dd8da2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

h11/_receivebuffer.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66

77
# Operations we want to support:
8-
# - find next \r\n or \r\n\r\n, or wait until there is one
8+
# - find next \r\n or \r\n\r\n (\n or \n\n are also acceptable),
9+
# or wait until there is one
910
# - read at-most-N bytes
1011
# Goals:
1112
# - on average, do this fast
@@ -40,7 +41,7 @@
4041
# processed a whole event, which could in theory be slightly more efficient
4142
# than the internal bytearray support.)
4243

43-
body_and_headers_delimiter_regex = re.compile(b"\n\r?\n", re.MULTILINE)
44+
blank_line_delimiter_regex = re.compile(b"\n\r?\n", re.MULTILINE)
4445
line_delimiter_regex = re.compile(b"\r?\n", re.MULTILINE)
4546

4647

@@ -50,7 +51,8 @@ def __init__(self):
5051
# These are both absolute offsets into self._data:
5152
self._start = 0
5253
self._looked_at = 0
53-
self._looked_for_regex = body_and_headers_delimiter_regex
54+
55+
self._looked_for_regex = blank_line_delimiter_regex
5456

5557
def __bool__(self):
5658
return bool(len(self))
@@ -129,7 +131,7 @@ def maybe_extract_lines(self):
129131
self._start += len(start_chunk)
130132
return []
131133
else:
132-
data = self.maybe_extract_until_next(body_and_headers_delimiter_regex, 3)
134+
data = self.maybe_extract_until_next(blank_line_delimiter_regex, 3)
133135
if data is None:
134136
return None
135137

0 commit comments

Comments
 (0)