From: Kenneth Reitz Date: Sun, 23 Oct 2011 15:00:36 +0000 (-0400) Subject: httpbasic authentication cleanup X-Git-Tag: v0.7.1~1^2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d23c4b94c11eadfba7554fa7216f2a30b04396ca;p=services%2Fpython-requests.git httpbasic authentication cleanup --- diff --git a/requests/auth.py b/requests/auth.py index 900a048..0a0402b 100644 --- a/requests/auth.py +++ b/requests/auth.py @@ -7,15 +7,17 @@ requests.auth This module contains the authentication handlers for Requests. """ -from base64 import encodestring as base64 +from base64 import base64 def http_basic(r, username, password): """Attaches HTTP Basic Authentication to the given Request object. Arguments should be considered non-positional. """ + username = str(username) + password = str(password) - auth_s = base64('%s:%s' % (username, password)).replace('\n', '') + auth_s = base64('%s:%s' % (username, password)) r.headers['Authorization'] = ('Basic %s' % auth_s) return r