Przeglądaj źródła

Allow for redirect through encoding for responseData to json parsing

NIX User 5 lat temu
rodzic
commit
573173dc2c
1 zmienionych plików z 4 dodań i 1 usunięć
  1. 4 1
      labkeyInterface.py

+ 4 - 1
labkeyInterface.py

@@ -1,5 +1,6 @@
 import urllib3
 #requests doesnt work as it lacks key password checking
+import chardet
 import json
 
 
@@ -39,6 +40,7 @@ class labkeyInterface:
         
 
 
+
     
     def get(self,url):
 
@@ -93,7 +95,8 @@ class labkeyInterface:
         url=self.GetLabkeyUrl()+'/login/whoAmI.view'
         response=self.get(url)
         self.cookie=response.getheader('Set-Cookie')
-        jsonData=json.loads(response.data)
+        encoding=chardet.detect(response.data)['encoding']
+        jsonData=json.loads(response.data.decode(encoding))
         return jsonData["CSRF"]