@@ -34,6 +34,7 @@ class StacValidate:
34
34
links (bool): Whether to additionally validate links (only works in default mode).
35
35
assets (bool): Whether to additionally validate assets (only works in default mode).
36
36
assets_open_urls (bool): Whether to open assets URLs when validating assets.
37
+ headers (dict): HTTP headers to include in the requests.
37
38
extensions (bool): Whether to only validate STAC object extensions.
38
39
custom (str): The local filepath or remote URL of a custom JSON schema to validate the STAC object.
39
40
verbose (bool): Whether to enable verbose output in recursive mode.
@@ -56,6 +57,7 @@ def __init__(
56
57
links : bool = False ,
57
58
assets : bool = False ,
58
59
assets_open_urls : bool = True ,
60
+ headers : dict = {},
59
61
extensions : bool = False ,
60
62
custom : str = "" ,
61
63
verbose : bool = False ,
@@ -70,6 +72,7 @@ def __init__(
70
72
self .links = links
71
73
self .assets = assets
72
74
self .assets_open_urls = assets_open_urls
75
+ self .headers : Dict = headers
73
76
self .recursive = recursive
74
77
self .max_depth = max_depth
75
78
self .extensions = extensions
@@ -125,7 +128,9 @@ def assets_validator(self) -> Dict:
125
128
assets = self .stac_content .get ("assets" )
126
129
if assets :
127
130
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
+ )
129
134
return initial_message
130
135
131
136
def links_validator (self ) -> Dict :
@@ -145,7 +150,7 @@ def links_validator(self) -> Dict:
145
150
for link in self .stac_content ["links" ]:
146
151
if not is_valid_url (link ["href" ]):
147
152
link ["href" ] = root_url + link ["href" ][1 :]
148
- link_request (link , initial_message )
153
+ link_request (link , initial_message , True , self . headers )
149
154
150
155
return initial_message
151
156
@@ -345,7 +350,9 @@ def recursive_validator(self, stac_type: str) -> bool:
345
350
self .stac_file = st + "/" + address
346
351
else :
347
352
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
+ )
349
356
self .stac_content ["stac_version" ] = self .version
350
357
stac_type = get_stac_type (self .stac_content ).lower ()
351
358
@@ -414,7 +421,7 @@ def validate_collections(self) -> None:
414
421
Returns:
415
422
None
416
423
"""
417
- collections = fetch_and_parse_file (str (self .stac_file ))
424
+ collections = fetch_and_parse_file (str (self .stac_file ), self . headers )
418
425
for collection in collections ["collections" ]:
419
426
self .schema = ""
420
427
self .validate_dict (collection )
@@ -437,7 +444,7 @@ def validate_item_collection(self) -> None:
437
444
"""
438
445
page = 1
439
446
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 )
441
448
self .validate_item_collection_dict (item_collection )
442
449
try :
443
450
if self .pages is not None :
@@ -450,7 +457,7 @@ def validate_item_collection(self) -> None:
450
457
next_link = link ["href" ]
451
458
self .stac_file = next_link
452
459
item_collection = fetch_and_parse_file (
453
- str (self .stac_file )
460
+ str (self .stac_file ), self . headers
454
461
)
455
462
self .validate_item_collection_dict (item_collection )
456
463
break
@@ -489,7 +496,7 @@ def run(self) -> bool:
489
496
and not self .item_collection
490
497
and not self .collections
491
498
):
492
- self .stac_content = fetch_and_parse_file (self .stac_file )
499
+ self .stac_content = fetch_and_parse_file (self .stac_file , self . headers )
493
500
494
501
stac_type = get_stac_type (self .stac_content ).upper ()
495
502
self .version = self .stac_content ["stac_version" ]
0 commit comments