mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +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, () => {
|
||||
res.timing.end('total')
|
||||
|
||||
res.setHeader(
|
||||
'Server-Timing',
|
||||
[]
|
||||
.concat(res.getHeader('Server-Timing') || [])
|
||||
.concat(res.timing.headers)
|
||||
.join(', ')
|
||||
)
|
||||
if (res.timing.headers.length > 0) {
|
||||
res.setHeader(
|
||||
'Server-Timing',
|
||||
[]
|
||||
.concat(res.getHeader('Server-Timing') || [])
|
||||
.concat(res.timing.headers)
|
||||
.join(', ')
|
||||
)
|
||||
}
|
||||
res.timing.clear()
|
||||
})
|
||||
|
||||
next()
|
||||
@ -35,7 +38,9 @@ class ServerTiming extends Timer {
|
||||
|
||||
end(...args) {
|
||||
const time = super.end(...args)
|
||||
this.headers.push(this.formatHeader(time))
|
||||
if (time) {
|
||||
this.headers.push(this.formatHeader(time))
|
||||
}
|
||||
return time
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user