From bcb30e56fd3939482daa59b166d21835d77d4f23 Mon Sep 17 00:00:00 2001 From: dave mankoff Date: Sun, 22 Jan 2012 17:15:10 -0500 Subject: [PATCH 1/2] fix curl basic auth --- tornado/curl_httpclient.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py index 8dfcb4a8..7d8faf36 100644 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@ -383,10 +383,10 @@ def _curl_setup_request(curl, request, buffer, headers): else: curl.setopt(pycurl.INFILESIZE, len(request.body)) - if request.auth_username and request.auth_password: - userpwd = "%s:%s" % (request.auth_username, request.auth_password) + if request.auth_username is not None: + userpwd = "%s:%s" % (request.auth_username, request.auth_password or '') curl.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC) - curl.setopt(pycurl.USERPWD, userpwd) + curl.setopt(pycurl.USERPWD, userpwd.encode('ascii')) logging.debug("%s %s (username: %r)", request.method, request.url, request.auth_username) else: From df23c039d5cf020333cabaf2190495ea7ab0936b Mon Sep 17 00:00:00 2001 From: dave mankoff Date: Mon, 23 Jan 2012 08:33:51 -0500 Subject: [PATCH 2/2] change encode('ascii') to utf8() --- tornado/curl_httpclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py index 7d8faf36..a338cb8d 100644 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@ -386,7 +386,7 @@ def _curl_setup_request(curl, request, buffer, headers): if request.auth_username is not None: userpwd = "%s:%s" % (request.auth_username, request.auth_password or '') curl.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC) - curl.setopt(pycurl.USERPWD, userpwd.encode('ascii')) + curl.setopt(pycurl.USERPWD, utf8(userpwd)) logging.debug("%s %s (username: %r)", request.method, request.url, request.auth_username) else: