Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Keep-Alive Header #2146

Merged
merged 2 commits into from
Feb 28, 2018
Merged

feat: support Keep-Alive Header #2146

merged 2 commits into from
Feb 28, 2018

Conversation

fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Feb 28, 2018

node-modules/agentkeepalive#58

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

@fengmk2
Copy link
Member Author

fengmk2 commented Feb 28, 2018

@codecov-io
Copy link

codecov-io commented Feb 28, 2018

Codecov Report

Merging #2146 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2146      +/-   ##
==========================================
+ Coverage   99.59%   99.59%   +<.01%     
==========================================
  Files          29       29              
  Lines         743      748       +5     
==========================================
+ Hits          740      745       +5     
  Misses          3        3
Impacted Files Coverage Δ
app/middleware/meta.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c828436...1db4217. Read the comment docs.

module.exports = options => {
module.exports = (options, app) => {
let server;
app.once('server', s => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app 上没有直接获取 server 的?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我直接加个 app.server 好了

// try to support Keep-Alive Header
if (server && server.keepAliveTimeout && server.keepAliveTimeout >= 1000 && ctx.header.connection !== 'close') {
const timeout = parseInt(server.keepAliveTimeout / 1000);
ctx.set('keep-alive', `timeout=${timeout}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果用户自己设置了这个 header 呢?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 header 不允许应用设置的,必须保证它的正确性

@fengmk2 fengmk2 force-pushed the support-keep-alive-header branch from 92e2229 to 1db4217 Compare February 28, 2018 08:52
@fengmk2
Copy link
Member Author

fengmk2 commented Feb 28, 2018

增加 app.server

@popomore
Copy link
Member

mm.app 是不是也考虑 emit server

@popomore popomore merged commit a739002 into master Feb 28, 2018
@popomore popomore deleted the support-keep-alive-header branch February 28, 2018 10:03
@fengmk2
Copy link
Member Author

fengmk2 commented Feb 28, 2018

@popomore 嗯,我加上

popomore pushed a commit that referenced this pull request Feb 28, 2018
fengmk2 added a commit to eggjs/mock that referenced this pull request Feb 28, 2018
popomore pushed a commit to eggjs/mock that referenced this pull request Feb 28, 2018
atian25 pushed a commit that referenced this pull request Apr 3, 2019
atian25 pushed a commit that referenced this pull request Apr 3, 2019
atian25 pushed a commit that referenced this pull request Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants