Skip to content

Commit 7dd820c

Browse files
Also allow image/x-jls
1 parent d905877 commit 7dd820c

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/dicomweb_client/web.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,13 +1077,13 @@ def _http_get_multipart(
10771077
default_media_type = '*/*'
10781078
supported_media_types = {
10791079
'1.2.840.10008.1.2.1': 'application/octet-stream',
1080-
'1.2.840.10008.1.2.5': ('image/x-dicom-rle', 'image/dicom-rle'),
1080+
'1.2.840.10008.1.2.5': ('image/dicom-rle', 'image/x-dicom-rle'),
10811081
'1.2.840.10008.1.2.4.50': 'image/jpeg',
10821082
'1.2.840.10008.1.2.4.51': 'image/jpeg',
10831083
'1.2.840.10008.1.2.4.57': 'image/jpeg',
10841084
'1.2.840.10008.1.2.4.70': 'image/jpeg',
1085-
'1.2.840.10008.1.2.4.80': 'image/jls',
1086-
'1.2.840.10008.1.2.4.81': 'image/jls',
1085+
'1.2.840.10008.1.2.4.80': ('image/jls', 'image/x-jls'),
1086+
'1.2.840.10008.1.2.4.81': ('image/jls', 'image/x-jls'),
10871087
'1.2.840.10008.1.2.4.90': 'image/jp2',
10881088
'1.2.840.10008.1.2.4.91': 'image/jp2',
10891089
'1.2.840.10008.1.2.4.92': 'image/jpx',
@@ -1201,13 +1201,13 @@ def _http_get_multipart_image(
12011201
""" # noqa: E501
12021202
headers = {}
12031203
supported_media_types = {
1204-
'1.2.840.10008.1.2.5': ('image/x-dicom-rle', 'image/dicom-rle'),
1204+
'1.2.840.10008.1.2.5': ('image/dicom-rle', 'image/x-dicom-rle'),
12051205
'1.2.840.10008.1.2.4.50': 'image/jpeg',
12061206
'1.2.840.10008.1.2.4.51': 'image/jpeg',
12071207
'1.2.840.10008.1.2.4.57': 'image/jpeg',
12081208
'1.2.840.10008.1.2.4.70': 'image/jpeg',
1209-
'1.2.840.10008.1.2.4.80': 'image/jls',
1210-
'1.2.840.10008.1.2.4.81': 'image/jls',
1209+
'1.2.840.10008.1.2.4.80': ('image/jls', 'image/x-jls'),
1210+
'1.2.840.10008.1.2.4.81': ('image/jls', 'image/x-jls'),
12111211
'1.2.840.10008.1.2.4.90': 'image/jp2',
12121212
'1.2.840.10008.1.2.4.91': 'image/jp2',
12131213
'1.2.840.10008.1.2.4.92': 'image/jpx',

tests/test_web.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -880,22 +880,31 @@ def test_retrieve_instance_frames_jp2(httpserver, client, cache_dir):
880880
assert request.accept_mimetypes[0][0][:35] == headers['content-type'][:35]
881881

882882

883-
def test_retrieve_instance_frames_jls(httpserver, client, cache_dir):
883+
@pytest.mark.parametrize(
884+
"media_type", ["image/dicom-rle", "image/x-dicom-rle"]
885+
)
886+
def test_retrieve_instance_frames_jls(
887+
httpserver,
888+
client,
889+
cache_dir,
890+
media_type
891+
):
884892
cache_filename = str(cache_dir.joinpath('retrieve_instance_pixeldata.jls'))
885893
with open(cache_filename, 'rb') as f:
886894
content = f.read()
887-
headers = {
888-
'content-type': 'multipart/related; type="image/jls"',
889-
}
895+
headers = {'content-type': f'multipart/related; type="{media_type}"',}
890896
httpserver.serve_content(content=content, code=200, headers=headers)
891897
study_instance_uid = '1.2.3'
892898
series_instance_uid = '1.2.4'
893899
sop_instance_uid = '1.2.5'
894900
frame_numbers = [114]
895901
frame_list = ','.join([str(n) for n in frame_numbers])
896902
result = client.retrieve_instance_frames(
897-
study_instance_uid, series_instance_uid, sop_instance_uid,
898-
frame_numbers, media_types=('image/jls', )
903+
study_instance_uid,
904+
series_instance_uid,
905+
sop_instance_uid,
906+
frame_numbers,
907+
media_types=(media_type, )
899908
)
900909
assert list(result) == [content]
901910
request = httpserver.requests[0]
@@ -909,7 +918,7 @@ def test_retrieve_instance_frames_jls(httpserver, client, cache_dir):
909918
assert request.accept_mimetypes[0][0][:35] == headers['content-type'][:35]
910919

911920
@pytest.mark.parametrize(
912-
"media_type", ["image/dicom-rle", "image/x-dicom-rle"]
921+
"media_type", ["image/dicom-rle", "image/x-dicom-rle"]
913922
)
914923
def test_retrieve_instance_frames_rle(
915924
httpserver,
@@ -920,9 +929,7 @@ def test_retrieve_instance_frames_rle(
920929
cache_filename = str(cache_dir.joinpath('retrieve_instance_pixeldata.rle'))
921930
with open(cache_filename, 'rb') as f:
922931
content = f.read()
923-
headers = {
924-
'content-type': f'multipart/related; type="{media_type}"',
925-
}
932+
headers = {'content-type': f'multipart/related; type="{media_type}"',}
926933
httpserver.serve_content(content=content, code=200, headers=headers)
927934
study_instance_uid = '1.2.3'
928935
series_instance_uid = '1.2.4'

0 commit comments

Comments
 (0)