@@ -192,7 +192,7 @@ class DICOMwebClient(object):
192192 def __init__ (self , url , username = None , password = None , ca_bundle = None ,
193193 cert = None , qido_url_prefix = None , wado_url_prefix = None ,
194194 stow_url_prefix = None , proxies = None , headers = None ,
195- callback = None ):
195+ callback = None , auth = None ):
196196 '''
197197 Parameters
198198 ----------
@@ -223,6 +223,8 @@ def __init__(self, url, username=None, password=None, ca_bundle=None,
223223 callback: Callable, optional
224224 callback function to manipulate responses generated from requests
225225 (see `requests event hooks <http://docs.python-requests.org/en/master/user/advanced/#event-hooks>`_)
226+ auth: requests.auth.AuthBase, optional
227+ a subclassed instance of `requests.auth.AuthBase` to be used for authentication with the DICOMweb server
226228
227229 ''' # noqa
228230 logger .debug ('initialize HTTP session' )
@@ -249,7 +251,7 @@ def __init__(self, url, username=None, password=None, ca_bundle=None,
249251 logger .debug ('use certificate file: {}' .format (cert ))
250252 self ._session .cert = cert
251253
252- # This regular expressin extracts the scheme and host name from the URL
254+ # This regular expression extracts the scheme and host name from the URL
253255 # and optionally the port number and prefix:
254256 # <scheme>://<host>(:<port>)(/<prefix>)
255257 # For example: "https://mydomain.com:443/wado-rs", where
@@ -284,6 +286,13 @@ def __init__(self, url, username=None, password=None, ca_bundle=None,
284286 self ._session .proxies = proxies
285287 if callback is not None :
286288 self ._session .hooks = {'response' : callback }
289+ if auth is not None :
290+ self ._session .auth = auth
291+ if username or password :
292+ logger .warning (
293+ 'Auth object specified. '
294+ 'Username and password ignored.'
295+ )
287296 if username is not None :
288297 if not password :
289298 raise ValueError (
0 commit comments