Skip to content

Commit

Permalink
Include X-Synapse-Version header in pkg.load requests (SYN-8474) (#4074)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cisphyx authored Jan 16, 2025
1 parent df25a32 commit ce88a74
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changes/8221696241d0c8e0142d663ec70cc6da.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
desc: Updated the ``pkg.load`` Storm command to include an ``X-Synapse-Version`` HTTP header
in requests.
prs: []
type: feat
...
4 changes: 3 additions & 1 deletion synapse/lib/storm.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,9 @@
$ssl = $lib.true
if $cmdopts.ssl_noverify { $ssl = $lib.false }
$resp = $lib.inet.http.get($cmdopts.url, ssl_verify=$ssl)
$headers = ({'X-Synapse-Version': $lib.str.join('.', $lib.version.synapse())})
$resp = $lib.inet.http.get($cmdopts.url, ssl_verify=$ssl, headers=$headers)
if ($resp.code != 200) {
$lib.warn("pkg.load got HTTP code: {code} for URL: {url}", code=$resp.code, url=$cmdopts.url)
Expand Down
3 changes: 3 additions & 0 deletions synapse/tests/test_lib_storm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2742,6 +2742,7 @@ async def test_storm_pkg_load(self):
class PkgHandler(s_httpapi.Handler):

async def get(self, name):
assert self.request.headers.get('X-Synapse-Version') == s_version.verstring

if name == 'notok':
self.sendRestErr('FooBar', 'baz faz')
Expand All @@ -2751,6 +2752,8 @@ async def get(self, name):

class PkgHandlerRaw(s_httpapi.Handler):
async def get(self, name):
assert self.request.headers.get('X-Synapse-Version') == s_version.verstring

self.set_header('Content-Type', 'application/json')
return self.write(pkg)

Expand Down

0 comments on commit ce88a74

Please sign in to comment.