Skip to content

Commit

Permalink
Fix invalid invocations of errors.LineTooLong.
Browse files Browse the repository at this point in the history
  • Loading branch information
filmor committed Oct 26, 2016
1 parent 973d8a8 commit 1f4d4c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion aiohttp/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class LineTooLong(BadHttpMessage):

def __init__(self, line, limit='Unknown'):
super().__init__(
"got more than %s bytes when reading %s" % (limit, line))
"Got more than %s bytes when reading %s." % (limit, line))


class InvalidHeader(BadHttpMessage):
Expand Down
10 changes: 6 additions & 4 deletions aiohttp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def parse_headers(self, lines):
header_length += len(line)
if header_length > self.max_field_size:
raise errors.LineTooLong(
'limit request headers fields size')
'request header field %s' % bname.decode("utf8"),
self.max_field_size)
bvalue.append(line)

# next line
Expand All @@ -113,7 +114,8 @@ def parse_headers(self, lines):
else:
if header_length > self.max_field_size:
raise errors.LineTooLong(
'limit request headers fields size')
'request header field %s' % bname.decode("utf8"),
self.max_field_size)

bvalue = bvalue.strip()

Expand Down Expand Up @@ -173,7 +175,7 @@ def __call__(self, out, buf):
raw_data = yield from buf.readuntil(
b'\r\n\r\n', self.max_headers)
except errors.LineLimitExceededParserError as exc:
raise errors.LineTooLong(exc.limit) from None
raise errors.LineTooLong('request header', exc.limit) from None

lines = raw_data.split(b'\r\n')

Expand Down Expand Up @@ -227,7 +229,7 @@ def __call__(self, out, buf):
raw_data = yield from buf.readuntil(
b'\r\n\r\n', self.max_line_size + self.max_headers)
except errors.LineLimitExceededParserError as exc:
raise errors.LineTooLong(exc.limit) from None
raise errors.LineTooLong('response header', exc.limit) from None

lines = raw_data.split(b'\r\n')

Expand Down

0 comments on commit 1f4d4c7

Please sign in to comment.