Skip to content
This repository was archived by the owner on Sep 1, 2021. It is now read-only.

Commit 89839dd

Browse files
committed
Updated reporting headers.
This lets us more accurately report on client type and version. It also keeps the User-Agent header free for whatever the platforms natural User-Agent value is.
1 parent ea65a52 commit 89839dd

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

swiftype_app_search/swiftype_request_session.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ def __init__(self, api_key, base_url):
1212

1313
headers = {
1414
'Authorization': "Bearer {}".format(api_key),
15-
'User-Agent': "swiftype-app-search-python/{}".format(swiftype_app_search.__version__),
15+
'X-Swiftype-Client': 'swiftype-app-search-python',
16+
'X-Swiftype-Client-Version': swiftype_app_search.__version__,
1617
'content-type': 'application/json; charset=utf8'
1718
}
1819
self.session.headers.update(headers)

tests/test_swiftype_request_session.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ def test_headers_initialization(self):
2828
headers_to_check = {
2929
k: v
3030
for k, v in iteritems(self.swiftype_session.session.headers)
31-
if k in ['Authorization', 'User-Agent']
31+
if k in ['Authorization', 'X-Swiftype-Client', 'X-Swiftype-Client-Version']
3232
}
3333
version = swiftype_app_search.__version__
3434
self.assertEqual(
3535
headers_to_check,
3636
{
3737
'Authorization': 'Bearer {}'.format(self.api_host_key),
38-
'User-Agent': 'swiftype-app-search-python/{}'.format(version)
38+
'X-Swiftype-Client': 'swiftype-app-search-python',
39+
'X-Swiftype-Client-Version': version
3940
}
4041
)
4142

0 commit comments

Comments
 (0)