Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurdarcet committed Mar 10, 2017
1 parent 5735c6a commit 51baae6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 1 addition & 3 deletions aiohttp/http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def feed_data(self, data,
if pos >= start_pos:
# line found
self._lines.append(data[start_pos:pos])
start_pos = pos + 2

# \r\n\r\n found
start_pos = pos + 2
if self._lines[-1] == EMPTY:
try:
msg = self.parse_message(self._lines)
Expand Down Expand Up @@ -150,8 +150,6 @@ def feed_data(self, data,
payload = EMPTY_PAYLOAD

messages.append((msg, payload))

start_pos = start_pos+2
else:
self._tail = data[start_pos:]
data = EMPTY
Expand Down
12 changes: 11 additions & 1 deletion tests/test_http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,24 @@ def test_parse(parser):
text = b'GET /test HTTP/1.1\r\n\r\n'
messages, upgrade, tail = parser.feed_data(text)
assert len(messages) == 1
msg = messages[0][0]
msg, _ = messages[0]
assert msg.compression is None
assert not msg.upgrade
assert msg.method == 'GET'
assert msg.path == '/test'
assert msg.version == (1, 1)


@asyncio.coroutine
def test_parse_body(parser):
text = b'GET /test HTTP/1.1\r\nContent-Length: 4\r\n\r\nbody'
messages, upgrade, tail = parser.feed_data(text)
assert len(messages) == 1
_, payload = messages[0]
body = yield from payload.read(4)
assert body == b'body'


def test_parse_delayed(parser):
text = b'GET /test HTTP/1.1\r\n'
messages, upgrade, tail = parser.feed_data(text)
Expand Down

0 comments on commit 51baae6

Please sign in to comment.