Skip to content

Instantly share code, notes, and snippets.

@smerritt
Created July 3, 2014 00:57
Show Gist options
  • Save smerritt/255ad07ee6989c0f44ae to your computer and use it in GitHub Desktop.
Save smerritt/255ad07ee6989c0f44ae to your computer and use it in GitHub Desktop.
chunked HTTP putter
#!/usr/bin/env python
import httplib
import time
conn = httplib.HTTPConnection('localhost', '6020')
conn.putrequest('PUT', '/sdb2/831/AUTH_test/c/o')
conn.putheader('Transfer-Encoding', 'chunked')
conn.putheader('Content-Type', 'application/octet-stream')
conn.putheader('X-Timestamp', "%016.05f" % time.time())
conn.endheaders()
for i in range(10):
conn.send('5\r\nabCde\r\n')
time.sleep(0.5)
conn.send('0\r\n\r\n')
resp = conn.getresponse()
print resp.status
conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment