Commit 79182cc6 authored by Sam Rushing's avatar Sam Rushing

http_file.read(): implement size argument

parent 69e7997d
...@@ -89,15 +89,18 @@ class http_file: ...@@ -89,15 +89,18 @@ class http_file:
else: else:
yield block yield block
# XXX implement <size> argument def read (self, size=0, join=True):
def read (self, join=True): "read from the file. join=False returns a generator, join=True returns a string."
"read the entire contents. join=False returns a generator, join=True returns a string." if size == 0:
r = (x for x in self.streamo.read_all()) r = (x for x in self.streamo.read_all())
if join: if join:
return ''.join (r) return ''.join (r)
else:
return r
else: else:
return r # ignore join argument
return self.streamo.read_exact (size)
def readline (self): def readline (self):
"read a newline-delimited line." "read a newline-delimited line."
if self.done_cv.done: if self.done_cv.done:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment