Skip to content

Instantly share code, notes, and snippets.

@dopuskh3
Created December 14, 2009 11:09
Show Gist options
  • Save dopuskh3/255980 to your computer and use it in GitHub Desktop.
Save dopuskh3/255980 to your computer and use it in GitHub Desktop.
import os, sys, httplib2, random
buf_min = 1024
buf_max = 2048
def postStress(uri):
f = open("/dev/urandom", "r")
h = httplib2.Http()
headers = { "Content-Type": "application/octet-stream" }
while True:
try:
bsize = random.randint(buf_min, buf_max)
buffer = f.read(bsize)
# post
(res, content) = h.request(uri, "POST", headers=headers, body=buffer)
print str(res)
except Exception, e:
print "Error (%s)"%str(e)
time.sleep(1)
continue
if __name__ == "__main__":
if len(sys.argv) < 2:
print "Usage %s <uri>"%sys.argv[0]
sys.exit(1)
uri = sys.argv[1]
postStress(uri)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment