[util] use function for HTTPBasicAuth
more lightweight and faster than a class
This commit is contained in:
@@ -521,16 +521,15 @@ CODES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class HTTPBasicAuth():
|
def HTTPBasicAuth(username, password):
|
||||||
__slots__ = ("authorization",)
|
authorization = b"Basic " + binascii.b2a_base64(
|
||||||
|
f"{username}:{password}".encode("latin1"), newline=False)
|
||||||
|
del username, password
|
||||||
|
|
||||||
def __init__(self, username, password):
|
def _apply(request):
|
||||||
self.authorization = b"Basic " + binascii.b2a_base64(
|
request.headers["Authorization"] = authorization
|
||||||
f"{username}:{password}".encode("latin1"), newline=False)
|
|
||||||
|
|
||||||
def __call__(self, request):
|
|
||||||
request.headers["Authorization"] = self.authorization
|
|
||||||
return request
|
return request
|
||||||
|
return _apply
|
||||||
|
|
||||||
|
|
||||||
class ModuleProxy():
|
class ModuleProxy():
|
||||||
|
|||||||
Reference in New Issue
Block a user