|
@@ -2,6 +2,14 @@ import urllib3
|
|
#requests doesnt work as it lacks key password checking
|
|
#requests doesnt work as it lacks key password checking
|
|
import json
|
|
import json
|
|
|
|
|
|
|
|
+def setContentType(headers,dataType):
|
|
|
|
+
|
|
|
|
+ if dataType=='text':
|
|
|
|
+ headers['Content-Type']="text/plain"
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+ headers['Content-Type']="application/"+dataType
|
|
|
|
+
|
|
|
|
|
|
class orthancInterface:
|
|
class orthancInterface:
|
|
|
|
|
|
@@ -52,12 +60,12 @@ class orthancInterface:
|
|
except urllib3.exceptions.HTTPError as e:
|
|
except urllib3.exceptions.HTTPError as e:
|
|
print(e)
|
|
print(e)
|
|
|
|
|
|
- def post(self,url,dataType,data):
|
|
|
|
|
|
+ def post(self,url,data,dataType):
|
|
|
|
|
|
#dataType is typically json or octet-stream
|
|
#dataType is typically json or octet-stream
|
|
debug=False
|
|
debug=False
|
|
headers=urllib3.util.make_headers(basic_auth=self.getBasicAuth())
|
|
headers=urllib3.util.make_headers(basic_auth=self.getBasicAuth())
|
|
- headers['Content-Type']="application/"+dataType#for files
|
|
|
|
|
|
+ setContentType(headers,dataType)
|
|
#add csrf;also sets self.cookie
|
|
#add csrf;also sets self.cookie
|
|
#headers["X-LABKEY-CSRF"]=self.getCSRF()
|
|
#headers["X-LABKEY-CSRF"]=self.getCSRF()
|
|
#doesn't seem like orthanc is big on security
|
|
#doesn't seem like orthanc is big on security
|
|
@@ -69,7 +77,7 @@ class orthancInterface:
|
|
except urllib3.exceptions.HTTPError as e:
|
|
except urllib3.exceptions.HTTPError as e:
|
|
print(e)
|
|
print(e)
|
|
|
|
|
|
- def put(self,url,data):
|
|
|
|
|
|
+ def put(self,url,data,dataType='octet-stream'):
|
|
|
|
|
|
debug=False
|
|
debug=False
|
|
|
|
|
|
@@ -77,7 +85,7 @@ class orthancInterface:
|
|
print("PUT: {}").format(url)
|
|
print("PUT: {}").format(url)
|
|
|
|
|
|
headers=urllib3.util.make_headers(basic_auth=self.getBasicAuth())
|
|
headers=urllib3.util.make_headers(basic_auth=self.getBasicAuth())
|
|
- headers["Content-Type"]="application/octet-stream"
|
|
|
|
|
|
+ setContentType(headers,dataType)
|
|
#add csrf
|
|
#add csrf
|
|
#headers["X-LABKEY-CSRF"]=self.getCSRF()
|
|
#headers["X-LABKEY-CSRF"]=self.getCSRF()
|
|
#headers["Cookie"]=self.cookie
|
|
#headers["Cookie"]=self.cookie
|