1
0
mirror of https://github.com/httpie/cli.git synced 2025-08-10 22:42:05 +02:00

Added support and tests for unicode support in sessions.

This commit is contained in:
Jakub Roztocil
2014-04-26 18:16:30 +02:00
parent e8a1c051f9
commit a3352af1d4
4 changed files with 38 additions and 13 deletions

View File

@@ -19,11 +19,16 @@ class HTTPBasicAuth(requests.auth.HTTPBasicAuth):
See https://github.com/jkbr/httpie/issues/212
"""
credentials = u'%s:%s' % (self.username, self.password)
token = b64encode(credentials.encode('utf8')).strip().decode('latin1')
r.headers['Authorization'] = 'Basic %s' % token
r.headers['Authorization'] = type(self).make_header(
self.username, self.password).encode('latin1')
return r
@staticmethod
def make_header(username, password):
credentials = u'%s:%s' % (username, password)
token = b64encode(credentials.encode('utf8')).strip().decode('latin1')
return 'Basic %s' % token
class BasicAuthPlugin(BuiltinAuthPlugin):