We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aa4b4fb commit c07b63eCopy full SHA for c07b63e
1 file changed
prometheus_client/exposition.py
@@ -2,14 +2,13 @@
2
3
from __future__ import unicode_literals
4
5
+import base64
6
import os
7
import socket
-import time
8
import threading
9
+import time
10
from contextlib import closing
11
from wsgiref.simple_server import make_server
-import base64
12
-import sys
13
14
from . import core
15
try:
@@ -146,13 +145,9 @@ def handle():
146
145
'''Handler that implements HTTP Basic Auth.
147
'''
148
if username is not None and password is not None:
149
- if sys.version_info >= (3,0):
150
- auth_value = bytes('{0}:{1}'.format(username, password), 'utf8')
151
- auth_token = str(base64.b64encode(auth_value), 'utf8')
152
- else:
153
- auth_value = '{0}:{1}'.format(username, password)
154
- auth_token = base64.b64encode(auth_value)
155
- auth_header = "Basic {0}".format(auth_token)
+ auth_value = '{0}:{1}'.format(username, password).encode('utf-8')
+ auth_token = base64.b64encode(auth_value)
+ auth_header = b'Basic ' + auth_token
156
headers.append(['Authorization', auth_header])
157
default_handler(url, method, timeout, headers, data)()
158
0 commit comments