mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 14:50:17 +00:00
Fix divide by zero error in drip
It occured when 'numbytes' parameter was set to 0. In this case 'drip' should return 400('Bad request').
This commit is contained in:
+5
-1
@@ -468,12 +468,16 @@ def drip():
|
||||
duration = float(args.get('duration', 2))
|
||||
numbytes = min(int(args.get('numbytes', 10)),(10 * 1024 * 1024)) # set 10MB limit
|
||||
code = int(args.get('code', 200))
|
||||
pause = duration / numbytes
|
||||
|
||||
delay = float(args.get('delay', 0))
|
||||
if delay > 0:
|
||||
time.sleep(delay)
|
||||
|
||||
if numbytes <= 0:
|
||||
response = Response('number of bytes must be positive', status=400)
|
||||
return response
|
||||
|
||||
pause = duration / numbytes
|
||||
def generate_bytes():
|
||||
for i in xrange(numbytes):
|
||||
yield u"*".encode('utf-8')
|
||||
|
||||
Reference in New Issue
Block a user