mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added 'Content-Version' header to outgoing webhook requests
refs https://github.com/TryGhost/Toolbox/issues/283 - The header is needed to signal to the webhook subscribers the content version they are being served. This should imrove API version compatibility and allow for the client to handle incoming data better
This commit is contained in:
parent
2a3be178ab
commit
a1e1feb125
2 changed files with 4 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
const debug = require('@tryghost/debug')('services:webhooks:trigger');
|
||||
const logging = require('@tryghost/logging');
|
||||
const ghostVersion = require('@tryghost/version');
|
||||
|
||||
class WebhookTrigger {
|
||||
/**
|
||||
|
@ -88,7 +89,8 @@ class WebhookTrigger {
|
|||
body: reqPayload,
|
||||
headers: {
|
||||
'Content-Length': Buffer.byteLength(reqPayload),
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Version': `v${ghostVersion.safe}`
|
||||
},
|
||||
timeout: 2 * 1000,
|
||||
retry: 5
|
||||
|
|
|
@ -76,6 +76,7 @@ describe('Webhook Service', function () {
|
|||
assert.deepEqual(requestStub.args[0][1].body, '{"data":[1]}');
|
||||
assert.equal(requestStub.args[0][1].headers['Content-Length'], 12);
|
||||
assert.equal(requestStub.args[0][1].headers['Content-Type'], 'application/json');
|
||||
assert.match(requestStub.args[0][1].headers['Content-Version'], /v\d+\.\d+/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue