mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-07 09:22:27 +00:00
fix: not send Server-Timing header if no timing info
This commit is contained in:
parent
c6d8e8ff66
commit
d9a0b5f61b
@ -15,13 +15,16 @@ export default options => (req, res, next) => {
|
|||||||
onHeaders(res, () => {
|
onHeaders(res, () => {
|
||||||
res.timing.end('total')
|
res.timing.end('total')
|
||||||
|
|
||||||
res.setHeader(
|
if (res.timing.headers.length > 0) {
|
||||||
'Server-Timing',
|
res.setHeader(
|
||||||
[]
|
'Server-Timing',
|
||||||
.concat(res.getHeader('Server-Timing') || [])
|
[]
|
||||||
.concat(res.timing.headers)
|
.concat(res.getHeader('Server-Timing') || [])
|
||||||
.join(', ')
|
.concat(res.timing.headers)
|
||||||
)
|
.join(', ')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
res.timing.clear()
|
||||||
})
|
})
|
||||||
|
|
||||||
next()
|
next()
|
||||||
@ -35,7 +38,9 @@ class ServerTiming extends Timer {
|
|||||||
|
|
||||||
end(...args) {
|
end(...args) {
|
||||||
const time = super.end(...args)
|
const time = super.end(...args)
|
||||||
this.headers.push(this.formatHeader(time))
|
if (time) {
|
||||||
|
this.headers.push(this.formatHeader(time))
|
||||||
|
}
|
||||||
return time
|
return time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user