Skip to content

Commit ed7c13b

Browse files
author
hackermd
committed
Remove boundary from multipart/related accept header
1 parent 8730eb4 commit ed7c13b

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

src/dicomweb_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '0.9.0'
1+
__version__ = '0.9.1'
22

33
from dicomweb_client.api import DICOMwebClient

src/dicomweb_client/api.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import logging
66
import email
77
import six
8-
from urllib3.filepost import choose_boundary
98
from io import BytesIO
109
from collections import OrderedDict
1110
if sys.version_info.major < 3:
@@ -400,9 +399,9 @@ def _http_get(self, url, params, headers):
400399
'''
401400
url += self._build_query_string(params)
402401
logger.debug('GET: {}'.format(url))
403-
resp = self._session.get(url=url, headers=headers)
404-
resp.raise_for_status()
405-
return resp
402+
response = self._session.get(url=url, headers=headers)
403+
response.raise_for_status()
404+
return response
406405

407406
def _http_get_application_json(self, url, **params):
408407
'''Performs a HTTP GET request that accepts "applicaton/dicom+json"
@@ -532,10 +531,7 @@ def _http_get_multipart_application_dicom(self, url, **params):
532531
DICOM data sets
533532
534533
'''
535-
content_type = (
536-
'multipart/related; type="application/dicom"; '
537-
'boundary="--{boundary}"'.format(boundary=choose_boundary())
538-
)
534+
content_type = 'multipart/related; type="application/dicom"'
539535
resp = self._http_get(url, params, {'Accept': content_type})
540536
datasets = self._decode_multipart_message(resp.content, resp.headers)
541537
return [pydicom.dcmread(BytesIO(ds)) for ds in datasets]
@@ -557,10 +553,7 @@ def _http_get_multipart_application_octet_stream(self, url, **params):
557553
content of HTTP message body parts
558554
559555
'''
560-
content_type = (
561-
'multipart/related; type="application/octet-stream"; '
562-
'boundary="--{boundary}"'.format(boundary=choose_boundary())
563-
)
556+
content_type = 'multipart/related; type="application/octet-stream"'
564557
resp = self._http_get(url, params, {'Accept': content_type})
565558
return self._decode_multipart_message(resp.content, resp.headers)
566559

@@ -587,11 +580,8 @@ def _http_get_multipart_image(self, url, image_format, **params):
587580
raise ValueError(
588581
'Image format "{}" is not supported.'.format(image_format)
589582
)
590-
content_type = (
591-
'multipart/related; type="image/{image_format}"; '
592-
'boundary="--{boundary}"'.format(
593-
image_format=image_format, boundary=choose_boundary()
594-
)
583+
content_type = 'multipart/related; type="image/{image_format}"'.format(
584+
image_format=image_format
595585
)
596586
resp = self._http_get(url, params, {'Accept': content_type})
597587
return self._decode_multipart_message(resp.content, resp.headers)

src/dicomweb_client/tests/test_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def test_retrieve_instance(httpserver, client, cache_dir):
211211
'/{sop_instance_uid}'.format(**locals())
212212
)
213213
assert request.path == expected_path
214-
assert request.accept_mimetypes[0][0][:45] == headers['content-type'][:45]
214+
assert request.accept_mimetypes[0][0][:43] == headers['content-type'][:43]
215215

216216

217217
def test_retrieve_instance_pixeldata_jpeg(httpserver, client, cache_dir):
@@ -239,7 +239,7 @@ def test_retrieve_instance_pixeldata_jpeg(httpserver, client, cache_dir):
239239
'/{sop_instance_uid}/frames/{frame_list}'.format(**locals())
240240
)
241241
assert request.path == expected_path
242-
assert request.accept_mimetypes[0][0][:38] == headers['content-type'][:38]
242+
assert request.accept_mimetypes[0][0][:36] == headers['content-type'][:36]
243243

244244

245245
def test_retrieve_instance_pixeldata_jp2(httpserver, client, cache_dir):
@@ -267,4 +267,4 @@ def test_retrieve_instance_pixeldata_jp2(httpserver, client, cache_dir):
267267
'/{sop_instance_uid}/frames/{frame_list}'.format(**locals())
268268
)
269269
assert request.path == expected_path
270-
assert request.accept_mimetypes[0][0][:37] == headers['content-type'][:37]
270+
assert request.accept_mimetypes[0][0][:35] == headers['content-type'][:35]

0 commit comments

Comments
 (0)