0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Updated oembed requests to use consistent timeout and user-agent

no issue

- added the same 2sec timeout and `Ghost` user-agent header to the `rel="alternate"` oembed request that we use for the initial html page request
This commit is contained in:
Kevin Ansfield 2020-04-07 15:29:22 +01:00
parent 1fcf82cde3
commit ce53c602a6
2 changed files with 10 additions and 2 deletions

View file

@ -157,7 +157,11 @@ function fetchOembedData(_url) {
// fetch oembed response from embedded rel="alternate" url // fetch oembed response from embedded rel="alternate" url
return request(oembedUrl, { return request(oembedUrl, {
method: 'GET', method: 'GET',
json: true json: true,
timeout: 2 * 1000,
headers: {
'user-agent': 'Ghost(https://github.com/TryGhost/Ghost)'
}
}).then((response) => { }).then((response) => {
// validate the fetched json against the oembed spec to avoid // validate the fetched json against the oembed spec to avoid
// leaking non-oembed responses // leaking non-oembed responses

View file

@ -111,7 +111,11 @@ function fetchOembedData(_url) {
// fetch oembed response from embedded rel="alternate" url // fetch oembed response from embedded rel="alternate" url
return request(oembedUrl, { return request(oembedUrl, {
method: 'GET', method: 'GET',
json: true json: true,
timeout: 2 * 1000,
headers: {
'user-agent': 'Ghost(https://github.com/TryGhost/Ghost)'
}
}).then((response) => { }).then((response) => {
// validate the fetched json against the oembed spec to avoid // validate the fetched json against the oembed spec to avoid
// leaking non-oembed responses // leaking non-oembed responses