diff Plugins/DicomWeb/DicomWeb.py @ 222:0f03ee6ffa80

DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 26 Feb 2019 17:34:32 +0100
parents af8e034f4262
children 230aede7f8d5
line wrap: on
line diff
--- a/Plugins/DicomWeb/DicomWeb.py	Mon Feb 25 12:41:15 2019 +0100
+++ b/Plugins/DicomWeb/DicomWeb.py	Tue Feb 26 17:34:32 2019 +0100
@@ -66,3 +66,24 @@
     }
 
     return DoPost(orthanc, uri, body, headers = headers)
+
+
+def DoGetMultipart(orthanc, uri, headers = {}):
+    answer = DoGetRaw(orthanc, uri, headers = headers)
+
+    header = ''
+    for i in answer[0]:
+        header += '%s: %s\r\n' % (i, answer[0][i])
+
+    msg = email.message_from_string(header + '\r\n' + answer[1])
+    if not msg.is_multipart():
+        raise Exception('Not a multipart message')
+    
+    result = []
+
+    for part in msg.walk():
+        payload = part.get_payload(decode=True)
+        if payload != None:
+            result.append(payload)
+
+    return result