File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 12
12
)
13
13
14
14
from urllib .request import urlopen
15
+ from urllib .request import Request
15
16
from urllib .error import HTTPError
16
17
17
18
import pystac
38
39
class StacIO (ABC ):
39
40
_default_io : Optional [Callable [[], "StacIO" ]] = None
40
41
42
+ def __init__ (self , headers : Optional [Dict [str , str ]] = None ):
43
+ self .headers = headers or {}
44
+
41
45
@abstractmethod
42
46
def read_text (self , source : HREF , * args : Any , ** kwargs : Any ) -> str :
43
47
"""Read text from the given URI.
@@ -289,7 +293,8 @@ def read_text_from_href(self, href: str) -> str:
289
293
href_contents : str
290
294
if parsed .scheme != "" :
291
295
try :
292
- with urlopen (href ) as f :
296
+ req = Request (href , headers = self .headers )
297
+ with urlopen (req ) as f :
293
298
href_contents = f .read ().decode ("utf-8" )
294
299
except HTTPError as e :
295
300
raise Exception ("Could not read uri {}" .format (href )) from e
You can’t perform that action at this time.
0 commit comments