Improve httpdriver authentication feature

This commit is contained in:
allegroai 2019-09-05 01:53:43 +03:00
parent 05364f0796
commit 2fb69ae951

View File

@ -184,7 +184,11 @@ class StorageHelper(object):
@classmethod
def get(cls, url, logger=None, **kwargs):
""" Get a storage helper instance for the given URL """
"""
Get a storage helper instance for the given URL
:return: StorageHelper instance
"""
# Handle URL substitution etc before locating the correct storage driver
url = cls._canonize_url(url)
@ -923,6 +927,7 @@ class _HttpDriver(object):
class _Container(object):
_default_backend_session = None
_default_files_server_host = None
def __init__(self, name, retries=5, **kwargs):
self.name = name
@ -932,7 +937,10 @@ class _HttpDriver(object):
if not self._default_backend_session:
from ..backend_interface.base import InterfaceBase
self._default_backend_session = InterfaceBase._get_default_session()
if url.startswith(self._default_backend_session.get_files_server_host()):
if self._default_files_server_host is None:
self._default_files_server_host = self._default_backend_session.get_files_server_host()
if url.startswith(self._default_files_server_host):
return self._default_backend_session.add_auth_headers({})
return None