Skip to content

Instantly share code, notes, and snippets.

@zain
Created June 4, 2012 22:25
Show Gist options
  • Save zain/2871180 to your computer and use it in GitHub Desktop.
Save zain/2871180 to your computer and use it in GitHub Desktop.
import httplib, base64
host = "server.com"
path = "/foo/bar"
username = "jess"
password = "hunter2"
http = httplib.HTTP(host)
http.putrequest("GET", path)
http.putheader("Host", self.host)
http.putheader("Accept", "*/*")
s = base64.encodestring("%s:%s" % (username, password))
http.putheader("Authorization", "Basic %s" % s)
http.endheaders()
errcode, errmsg, headers = http.getreply()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment