Skip to content

Instantly share code, notes, and snippets.

@davidphasson
Created May 27, 2010 19:20
Show Gist options
  • Select an option

  • Save davidphasson/416223 to your computer and use it in GitHub Desktop.

Select an option

Save davidphasson/416223 to your computer and use it in GitHub Desktop.

Revisions

  1. funtaff created this gist May 27, 2010.
    29 changes: 29 additions & 0 deletions test.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #!/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)