Skip to content

Commit 5b3ec7c

Browse files
committed
fix headers maybe
1 parent f92b65a commit 5b3ec7c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pystac_client/cli.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
logger = logging.getLogger(__name__)
1515

1616

17-
def search(url=STAC_URL, matched=False, save=None, **kwargs):
17+
def search(url=STAC_URL, matched=False, save=None, headers=None, **kwargs):
1818
""" Main function for performing a search """
1919

2020
try:
21-
catalog = Client.open(url)
21+
catalog = Client.open(url, headers=headers)
2222
search = catalog.search(**kwargs)
2323

2424
if matched:
@@ -51,7 +51,7 @@ def parse_args(args):
5151
parent.add_argument('--url', help='Root Catalog URL', default=os.getenv('STAC_URL', None))
5252
parent.add_argument('--limit', help='Page size limit', type=int, default=500)
5353
parent.add_argument('--headers',
54-
help='Additional request headers (JSON file or string)',
54+
help='Additional request headers (JSON string)',
5555
default=None)
5656

5757
subparsers = parser0.add_subparsers(dest='command')
@@ -106,6 +106,10 @@ def parse_args(args):
106106
else:
107107
parsed_args['intersects'] = data
108108

109+
# if headers provided, parse it
110+
if 'headers' in parsed_args:
111+
parsed_args['headers'] = json.loads(parsed_args['headers'])
112+
109113
return parsed_args
110114

111115

pystac_client/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def __init__(self,
4848
extra_fields=None,
4949
href=None,
5050
catalog_type=None,
51-
conformance=None):
51+
conformance=None,
52+
headers=None):
5253
super().__init__(id=id,
5354
description=description,
5455
title=title,
@@ -66,7 +67,7 @@ def __init__(self,
6667
'API does not conform to {ConformanceClasses.STAC_API_CORE}. Must contain one of the following '
6768
f'URIs to conform (preferably the first):\n\t{allowed_uris}.')
6869

69-
self.headers = {}
70+
self.headers = headers
7071

7172
def __repr__(self):
7273
return '<Catalog id={}>'.format(self.id)

0 commit comments

Comments
 (0)