Skip to content

Instantly share code, notes, and snippets.

@davidphasson
Created May 27, 2010 19:20
Show Gist options
  • Save davidphasson/416223 to your computer and use it in GitHub Desktop.
Save davidphasson/416223 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os, sys, httplib, base64, pprint
pp = pprint.PrettyPrinter(indent=4)
headers = {
# "x-isi-set-location": sys.argv[2],
}
conn = httplib.HTTPConnection("www.loni.ucla.edu", 80)
#conn.set_debuglevel(3)
conn.connect()
#conn.request("POST", "/1" + sys.argv[1], headers=headers)
#conn.request("GET", "/1/ifs/beta" + sys.argv[1], headers=headers)
conn.request("GET", "/index.php", headers=headers)
resp = conn.getresponse()
conn.close()
print "%d - %s" % (resp.status, resp.reason)
# Some header fields to iterate through, can't figure out how to get them all
fields = ( "Server", "Date", "Content-Type", "Content-Length" )
for item in fields:
print "%s: %s" % (item, resp.getheader(item))
data = resp.read()
print data
print "My Length: %d" % len(data)
#pp.pprint(data2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment