@@ -359,15 +359,21 @@ class DRSObject:
359359 _http_client : HttpClient
360360 _url : furl
361361
362- def get (self , access_method : AccessMethod = AccessMethod .https ) -> Access :
362+ def get (self ,
363+ access_method : AccessMethod = AccessMethod .https ,
364+ access_headers : Mapping [str , str ] | None = None
365+ ) -> Access :
363366 """
364367 Returns access to the content of the data object identified by the
365368 given URI. The scheme of the URL in the returned access object depends
366369 on the access method specified.
367370 """
368- return self ._get (access_method )
371+ return self ._get (access_method , access_headers )
369372
370- def _get (self , access_method : AccessMethod ) -> Access :
373+ def _get (self ,
374+ access_method : AccessMethod ,
375+ access_headers : Mapping [str , str ] | None
376+ ) -> Access :
371377 url = self ._url
372378 while True :
373379 response = self ._request (url )
@@ -387,9 +393,9 @@ def _get(self, access_method: AccessMethod) -> Access:
387393 # https://github.com/ga4gh/data-repository-service-schemas/issues/361
388394 assert access_method is AccessMethod .gs , R (
389395 'Unexpected access method' , access_method )
390- return self ._get_access (access_id , AccessMethod .https )
396+ return self ._get_access (access_id , AccessMethod .https , access_headers )
391397 elif access_id is not None :
392- return self ._get_access (access_id , access_method )
398+ return self ._get_access (access_id , access_method , access_headers )
393399 elif access_url is not None :
394400 scheme = furl (access_url ['url' ]).scheme
395401 assert scheme == access_method .scheme , R (
@@ -406,11 +412,15 @@ def _get(self, access_method: AccessMethod) -> Access:
406412 else :
407413 raise DRSStatusException (url , response )
408414
409- def _get_access (self , access_id : str , access_method : AccessMethod ) -> Access :
415+ def _get_access (self ,
416+ access_id : str ,
417+ access_method : AccessMethod ,
418+ access_headers : Mapping [str , str ] | None
419+ ) -> Access :
410420 url = self ._url .copy ()
411421 url .path .add (['access' , access_id ])
412422 while True :
413- response = self ._request (url )
423+ response = self ._request (url , headers = access_headers )
414424 if response .status == 200 :
415425 response_data = json_dict (json .loads (response .data ))
416426 scheme = furl (response_data ['url' ]).scheme
@@ -429,8 +439,8 @@ def _get_access(self, access_id: str, access_method: AccessMethod) -> Access:
429439 else :
430440 raise DRSStatusException (url , response )
431441
432- def _request (self , url : furl ) -> urllib3 .BaseHTTPResponse :
433- return self ._http_client .request ('GET' , str (url ), redirect = False )
442+ def _request (self , url : furl , ** kwargs ) -> urllib3 .BaseHTTPResponse :
443+ return self ._http_client .request ('GET' , str (url ), ** kwargs , redirect = False )
434444
435445
436446class DRSStatusException (Exception ):
0 commit comments