Skip to content

Commit 8293b76

Browse files
committed
Add X-Planet-App client header to outgoing requests
1 parent ca4849d commit 8293b76

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

planet/api/dispatch.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,15 @@ class RequestsDispatcher(object):
136136
def __init__(self, workers=4):
137137
# general session for sync api calls
138138
self.session = RedirectSession()
139-
self.session.headers.update({'User-Agent': _get_user_agent()})
139+
self.session.headers.update({
140+
'User-Agent': _get_user_agent(),
141+
'X-Planet-App': 'python-client'
142+
})
140143
# ensure all calls to the session are throttled
141144
self.session.request = _Throttler().wrap(self.session.request)
142145
# the asyncpool is reserved for long-running async tasks
143-
self._asyncpool = FuturesSession(
144-
max_workers=workers,
145-
session=self.session)
146+
self._asyncpool = FuturesSession(max_workers=workers,
147+
session=self.session)
146148

147149
def response(self, request):
148150
return Response(request, self)

planet/scripts/item_asset_types.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@
9494

9595
def _get_json_or_raise(url, timeout=11):
9696
api_key = find_api_key()
97-
headers = {'User-Agent': _get_user_agent(),
98-
'Authorization': 'api-key %s' % api_key}
97+
headers = {
98+
'User-Agent': _get_user_agent(),
99+
'X-Planet-App': 'python-client',
100+
'Authorization': 'api-key %s' % api_key
101+
}
99102
resp = requests.get(url, timeout=timeout, headers=headers)
100103
resp.raise_for_status()
101104
return resp.json()

0 commit comments

Comments
 (0)