Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Digest authentication #700

Merged
merged 1 commit into from

3 participants

@icaromedeiros

Support to digest authentication on PyCURL HTTP client.

@rodsenra

Hey guys, this is a small but very useful patch for those that are stuck with DIGEST authentication.
+1 for the patch.

@bdarnell bdarnell merged commit 98b0262 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 22, 2013
  1. @icaromedeiros

    digest authentication

    icaromedeiros authored
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.