comparison OrthancServer/Resources/Samples/Python/Replicate.py @ 4625:844ec5ecb6ef

Fix "OrthancServer/Resources/Samples/Python/Replicate.py" for Python 3.x
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 19 Apr 2021 10:28:24 +0200
parents d9473bd5ed43
children 7053502fbf97
comparison
equal deleted inserted replaced
4620:926fa5ef8b4f 4625:844ec5ecb6ef
49 # This is a custom reimplementation of the 49 # This is a custom reimplementation of the
50 # "Http.add_credentials()" method for Basic HTTP Access 50 # "Http.add_credentials()" method for Basic HTTP Access
51 # Authentication (for some weird reason, this method does not 51 # Authentication (for some weird reason, this method does not
52 # always work) 52 # always work)
53 # http://en.wikipedia.org/wiki/Basic_access_authentication 53 # http://en.wikipedia.org/wiki/Basic_access_authentication
54 headers['authorization'] = 'Basic ' + base64.b64encode(username + ':' + password) 54
55 # The ".encode()" and ".decode()" below fix the following issue:
56 # https://groups.google.com/g/orthanc-users/c/KZ_iYOet5IQ/m/AUQWiSiAAQAJ
57 credentials = (username + ':' + password)
58 credentials_base64 = base64.b64encode(credentials.encode("ascii")).decode("ascii")
59 headers['authorization'] = 'Basic ' + credentials_base64
55 60
56 return headers 61 return headers
57 62
58 63
59 def GetBaseUrl(parsedUrl): 64 def GetBaseUrl(parsedUrl):