Skip to content

Commit b5540b7

Browse files
committed
ENH: Avoid user warning about missing multipart response
Observed warning: UserWarning: message sent by origin server in response to GET request of Retrieve Instance transaction was not compliant with the DICOM standard, message body shall have Content-Type 'multipart/related; type="application/dicom"' rather than "application/dicom"
1 parent 0fb0030 commit b5540b7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/test_web.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,20 @@ def test_retrieve_instance_singlepart(httpserver, client, cache_dir):
776776
cache_filename = str(cache_dir.joinpath('file.dcm'))
777777
with open(cache_filename, 'rb') as f:
778778
data = f.read()
779+
media_type = 'application/dicom'
780+
boundary = 'boundary'
779781
headers = {
780-
'content-type': 'application/dicom'
782+
'content-type': (
783+
'multipart/related; '
784+
f'type="{media_type}"; '
785+
f'boundary="{boundary}"'
786+
),
781787
}
782-
httpserver.serve_content(content=data, code=200, headers=headers)
788+
message = DICOMwebClient._encode_multipart_message(
789+
content=[data],
790+
content_type=headers['content-type']
791+
)
792+
httpserver.serve_content(content=message, code=200, headers=headers)
783793
study_instance_uid = '1.2.3'
784794
series_instance_uid = '1.2.4'
785795
sop_instance_uid = '1.2.5'

0 commit comments

Comments
 (0)