Skip to content

Commit

Permalink
fix byte streaming endpoint in python3
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin1024 committed Jun 9, 2014
1 parent 16d6fea commit 7e2214c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion httpbin/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def generate_bytes():
chunks = []

for i in xrange(n):
chunks.append(chr(random.randint(0, 255)))
chunks.append(os.urandom(1))
if len(chunks) == chunk_size:
yield(bytes().join(chunks))
chunks = []
Expand Down
5 changes: 5 additions & 0 deletions test_httpbin.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ def test_get_bytes(self):
self.assertEqual(len(response.get_data()), 1024)
self.assertEqual(response.status_code, 200)

def test_stream_bytes(self):
response = self.app.get('/stream-bytes/1024')
self.assertEqual(len(response.get_data()), 1024)
self.assertEqual(response.status_code, 200)


if __name__ == '__main__':
unittest.main()

0 comments on commit 7e2214c

Please sign in to comment.