Browse files

Merge pull request #700 from icaromedeiros/master

Digest authentication for curl_httpclient
  • Loading branch information...
2 parents e0e8f7e + e8bc6af commit 98b0262d573e5862c5e76d4dc2a2ffd21de7b53a @bdarnell bdarnell committed Apr 13, 2013
Showing with 11 additions and 4 deletions.
  1. +6 −1 tornado/curl_httpclient.py
  2. +5 −3 tornado/httpclient.py
View
7 tornado/curl_httpclient.py
@@ -411,7 +411,12 @@ def ioctl(cmd):
if request.auth_username is not None:
userpwd = "%s:%s" % (request.auth_username, request.auth_password or '')
- curl.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC)
+
+ if request.auth_mode is None or request.auth_mode == "basic":
+ curl.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC)
+ elif request.auth_mode == "digest":
+ curl.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_DIGEST)
+
curl.setopt(pycurl.USERPWD, native_str(userpwd))
gen_log.debug("%s %s (username: %r)", request.method, request.url,
request.auth_username)
View
8 tornado/httpclient.py
@@ -242,7 +242,7 @@ class HTTPRequest(object):
validate_cert=True)
def __init__(self, url, method="GET", headers=None, body=None,
- auth_username=None, auth_password=None,
+ auth_username=None, auth_password=None, auth_mode=None,
connect_timeout=None, request_timeout=None,
if_modified_since=None, follow_redirects=None,
max_redirects=None, user_agent=None, use_gzip=None,
@@ -259,8 +259,9 @@ def __init__(self, url, method="GET", headers=None, body=None,
:arg string method: HTTP method, e.g. "GET" or "POST"
:arg headers: Additional HTTP headers to pass on the request
:type headers: `~tornado.httputil.HTTPHeaders` or `dict`
- :arg string auth_username: Username for HTTP "Basic" authentication
- :arg string auth_password: Password for HTTP "Basic" authentication
+ :arg string auth_username: Username for HTTP authentication
+ :arg string auth_password: Password for HTTP authentication
+ :arg string auth_mode: Authentication mode (basic, digest)
:arg float connect_timeout: Timeout for initial connection in seconds
:arg float request_timeout: Timeout for entire request in seconds
:arg if_modified_since: Timestamp for ``If-Modified-Since`` header
@@ -322,6 +323,7 @@ def __init__(self, url, method="GET", headers=None, body=None,
self.body = utf8(body)
self.auth_username = auth_username
self.auth_password = auth_password
+ self.auth_mode = auth_mode
self.connect_timeout = connect_timeout
self.request_timeout = request_timeout
self.follow_redirects = follow_redirects

0 comments on commit 98b0262

Please sign in to comment.