Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mahmoud/hematite
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoud committed Jun 2, 2014
2 parents 55d3c68 + df22b35 commit 652da17
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions hematite/raw/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,16 +438,22 @@ def _make_reader(self):
if self.content_length is None
else self.content_length)

def _stop():
self.body.complete(self.bytes_read)
self.state = M.Complete

while not self.complete:
t, read = yield M.NeedData(amount=self.bytes_remaining)
assert t == M.HaveData.type

amount = len(read)

if not amount:
# Connection: close
if self.content_length is None or self.bytes_remaining <= 0:
self.state = M.Complete
continue
_stop()
break

raise IncompleteBody('Could not read remaining {0} '
'bytes'.format(self.bytes_remaining))

Expand All @@ -459,8 +465,7 @@ def _make_reader(self):
self.bytes_remaining = (self.content_length - self.bytes_read)

if self.bytes_remaining <= 0:
self.body.complete(self.bytes_read)
self.state = M.Complete
_stop()

while True:
yield M.Complete
Expand Down

0 comments on commit 652da17

Please sign in to comment.