|
23 | 23 | from lib.core.common import getSafeExString |
24 | 24 | from lib.core.common import saveConfig |
25 | 25 | from lib.core.common import unArrayizeValue |
| 26 | +from lib.core.convert import base64encode |
26 | 27 | from lib.core.convert import hexencode |
27 | 28 | from lib.core.convert import dejsonize |
28 | 29 | from lib.core.convert import jsonize |
@@ -654,7 +655,7 @@ def download(taskid, target, filename): |
654 | 655 | logger.debug("[%s] Retrieved content of file %s" % (taskid, target)) |
655 | 656 | with open(path, 'rb') as inf: |
656 | 657 | file_content = inf.read() |
657 | | - return jsonize({"success": True, "file": file_content.encode("base64")}) |
| 658 | + return jsonize({"success": True, "file": base64encode(file_content)}) |
658 | 659 | else: |
659 | 660 | logger.warning("[%s] File does not exist %s" % (taskid, target)) |
660 | 661 | return jsonize({"success": False, "message": "File does not exist"}) |
@@ -722,7 +723,7 @@ def _client(url, options=None): |
722 | 723 | headers = {"Content-Type": "application/json"} |
723 | 724 |
|
724 | 725 | if DataStore.username or DataStore.password: |
725 | | - headers["Authorization"] = "Basic %s" % ("%s:%s" % (DataStore.username or "", DataStore.password or "")).encode("base64").strip() |
| 726 | + headers["Authorization"] = "Basic %s" % base64encode("%s:%s" % (DataStore.username or "", DataStore.password or "")) |
726 | 727 |
|
727 | 728 | req = urllib2.Request(url, data, headers) |
728 | 729 | response = urllib2.urlopen(req) |
|
0 commit comments