File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
'use strict' ;
6
6
7
+ const semver = require ( 'semver' ) ;
8
+
7
9
module . exports = options => {
8
10
return async function meta ( ctx , next ) {
9
11
if ( options . logging ) {
@@ -13,9 +15,12 @@ module.exports = options => {
13
15
// total response time header
14
16
ctx . set ( 'x-readtime' , Date . now ( ) - ctx . starttime ) ;
15
17
16
- // try to support Keep-Alive Header
18
+ // Node.js >=14.8.0 will set Keep-Alive Header, see https://github.com/nodejs/node/pull/34561
19
+ const shouldPatchKeepAliveHeader = semver . lt ( process . version , '14.8.0' ) ;
20
+
21
+ // try to support Keep-Alive Header when < 14.8.0
17
22
const server = ctx . app . server ;
18
- if ( server && server . keepAliveTimeout && server . keepAliveTimeout >= 1000 && ctx . header . connection !== 'close' ) {
23
+ if ( shouldPatchKeepAliveHeader && server && server . keepAliveTimeout && server . keepAliveTimeout >= 1000 && ctx . header . connection !== 'close' ) {
19
24
/**
20
25
* use Math.floor instead of parseInt. More: https://github.com/eggjs/egg/pull/2702
21
26
*/
Original file line number Diff line number Diff line change 49
49
"ms" : " ^2.1.1" ,
50
50
"mz" : " ^2.7.0" ,
51
51
"on-finished" : " ^2.3.0" ,
52
+ "semver" : " ^7.3.2" ,
52
53
"sendmessage" : " ^1.1.0" ,
53
54
"urllib" : " ^2.33.0" ,
54
55
"utility" : " ^1.15.0" ,
You can’t perform that action at this time.
0 commit comments