@@ -34,6 +34,7 @@ class StacValidate:
3434 links (bool): Whether to additionally validate links (only works in default mode).
3535 assets (bool): Whether to additionally validate assets (only works in default mode).
3636 assets_open_urls (bool): Whether to open assets URLs when validating assets.
37+ headers (dict): HTTP headers to include in the requests.
3738 extensions (bool): Whether to only validate STAC object extensions.
3839 custom (str): The local filepath or remote URL of a custom JSON schema to validate the STAC object.
3940 verbose (bool): Whether to enable verbose output in recursive mode.
@@ -56,6 +57,7 @@ def __init__(
5657 links : bool = False ,
5758 assets : bool = False ,
5859 assets_open_urls : bool = True ,
60+ headers : dict = {},
5961 extensions : bool = False ,
6062 custom : str = "" ,
6163 verbose : bool = False ,
@@ -70,6 +72,7 @@ def __init__(
7072 self .links = links
7173 self .assets = assets
7274 self .assets_open_urls = assets_open_urls
75+ self .headers : Dict = headers
7376 self .recursive = recursive
7477 self .max_depth = max_depth
7578 self .extensions = extensions
@@ -125,7 +128,9 @@ def assets_validator(self) -> Dict:
125128 assets = self .stac_content .get ("assets" )
126129 if assets :
127130 for asset in assets .values ():
128- link_request (asset , initial_message , self .assets_open_urls )
131+ link_request (
132+ asset , initial_message , self .assets_open_urls , self .headers
133+ )
129134 return initial_message
130135
131136 def links_validator (self ) -> Dict :
@@ -145,7 +150,7 @@ def links_validator(self) -> Dict:
145150 for link in self .stac_content ["links" ]:
146151 if not is_valid_url (link ["href" ]):
147152 link ["href" ] = root_url + link ["href" ][1 :]
148- link_request (link , initial_message )
153+ link_request (link , initial_message , True , self . headers )
149154
150155 return initial_message
151156
@@ -345,7 +350,9 @@ def recursive_validator(self, stac_type: str) -> bool:
345350 self .stac_file = st + "/" + address
346351 else :
347352 self .stac_file = address
348- self .stac_content = fetch_and_parse_file (str (self .stac_file ))
353+ self .stac_content = fetch_and_parse_file (
354+ str (self .stac_file ), self .headers
355+ )
349356 self .stac_content ["stac_version" ] = self .version
350357 stac_type = get_stac_type (self .stac_content ).lower ()
351358
@@ -414,7 +421,7 @@ def validate_collections(self) -> None:
414421 Returns:
415422 None
416423 """
417- collections = fetch_and_parse_file (str (self .stac_file ))
424+ collections = fetch_and_parse_file (str (self .stac_file ), self . headers )
418425 for collection in collections ["collections" ]:
419426 self .schema = ""
420427 self .validate_dict (collection )
@@ -437,7 +444,7 @@ def validate_item_collection(self) -> None:
437444 """
438445 page = 1
439446 print (f"processing page { page } " )
440- item_collection = fetch_and_parse_file (str (self .stac_file ))
447+ item_collection = fetch_and_parse_file (str (self .stac_file ), self . headers )
441448 self .validate_item_collection_dict (item_collection )
442449 try :
443450 if self .pages is not None :
@@ -450,7 +457,7 @@ def validate_item_collection(self) -> None:
450457 next_link = link ["href" ]
451458 self .stac_file = next_link
452459 item_collection = fetch_and_parse_file (
453- str (self .stac_file )
460+ str (self .stac_file ), self . headers
454461 )
455462 self .validate_item_collection_dict (item_collection )
456463 break
@@ -489,7 +496,7 @@ def run(self) -> bool:
489496 and not self .item_collection
490497 and not self .collections
491498 ):
492- self .stac_content = fetch_and_parse_file (self .stac_file )
499+ self .stac_content = fetch_and_parse_file (self .stac_file , self . headers )
493500
494501 stac_type = get_stac_type (self .stac_content ).upper ()
495502 self .version = self .stac_content ["stac_version" ]
0 commit comments