From 488cf5d59fadacb416768f58749c94769d486903 Mon Sep 17 00:00:00 2001 From: Christopher Pickering Date: Wed, 12 May 2021 12:37:29 -0500 Subject: [PATCH] add functions that were removed in werkszeug. for #165 --- flask_apscheduler/auth.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/flask_apscheduler/auth.py b/flask_apscheduler/auth.py index f11158b..740d875 100644 --- a/flask_apscheduler/auth.py +++ b/flask_apscheduler/auth.py @@ -17,7 +17,21 @@ import base64 from flask import request -from werkzeug.http import bytes_to_wsgi, wsgi_to_bytes + + +def wsgi_to_bytes(data): + """coerce wsgi unicode represented bytes to real ones""" + if isinstance(data, bytes): + return data + return data.encode("latin1") # XXX: utf8 fallback? + + +def bytes_to_wsgi(data): + assert isinstance(data, bytes), "data must be bytes" + if isinstance(data, str): + return data + else: + return data.decode("latin1") def get_authorization_header():