Permalink
Browse files

Enhances Cherokee-tweak for supporting Digest and Basic authentication

methods. Before, only Basic or no authentication was possible.

git-svn-id: svn://cherokee-project.com/cherokee/trunk@6628 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
1 parent 055b72b commit 398c9b6bc0e766c06d8ad1efe688f389a0b60f19 @alobbs alobbs committed May 17, 2011
Showing with 11 additions and 10 deletions.
  1. +11 −10 cherokee/cherokee-tweak
@@ -144,27 +144,28 @@ def parse_args():
raise SystemExit
-def http_request (path, post_info=None, method=None):
+def http_request (url_py, post_info=None, method=None):
# Authtentication
if user or password:
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password (None, url, user, password)
- authhandler = urllib2.HTTPBasicAuthHandler (passman)
- opener = urllib2.build_opener (authhandler)
+ authhandler_digest = urllib2.HTTPDigestAuthHandler (passman)
+ authhandler_basic = urllib2.HTTPBasicAuthHandler (passman)
+
+ opener = urllib2.build_opener (authhandler_digest, authhandler_basic)
urllib2.install_opener (opener)
else:
opener = urllib2.build_opener (urllib2.HTTPHandler)
# Request
- try:
- request = urllib2.Request (path, post_info)
- if method:
- request.get_method = lambda: method
+ request = urllib2.Request (url_py, post_info)
+ if method:
+ request.get_method = lambda: method
- conn = opener.open (request)
-
- ## conn = urllib2.urlopen (url_py, post_info)
+ # Perform
+ try:
+ conn = urllib2.urlopen (url_py, post_info)
except urllib2.HTTPError, e:
if e.code == 401:
print >> sys.stderr, "Error in Authentication"

0 comments on commit 398c9b6

Please sign in to comment.