-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
refactor: replaced _implicitHeader #908
base: master
Are you sure you want to change the base?
refactor: replaced _implicitHeader #908
Conversation
d2392b6
to
12eb09c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the purpose of the added test code is in relation to this change, as (1) reverting the changes in index.js
doesn't affect the outcome of the tests and (2) looking at the test code it is just a http/2 server returning "Hello, world!" and asserting that that is the case...
Sweet. Also, I am going to sleep now, but meant to update here that I think I was using a Node.js version without http/2 earlier when I tested; I needed to get back and double-check that. |
cf9cc21
to
4d16065
Compare
cf9cc21
to
92d05cc
Compare
Ok, I have split the initial commit (d021958) into two separate commits (92d05cc, df7163e) for clarity.
I ran the GH actions on my forked repository and here are the results for all the commits: |
I'm not sure if this change will provide full http2 support. IMHO, changing from an undocumented API to a documented API is a move in the right direction. @dougwilson, do you think we should add a repeat of all the tests for http2? |
Yep, makes sense. I assume the line right above that should be changed as well, right? |
6770cbf
to
416ae6f
Compare
Yup, agreed. |
Gotcha. Why spread it across a bunch of PRs? We can just fix the undocumented API usage at once. It's better for making a release, as making a release can cause folks to break. It is sad but true. I usually err on this being a semver major so we should get them all fixed at once. |
I'm not sure what that means. It is used in the line right above the one you changed in the PR. Line 275 in 1010fad
|
Ah, my bad, I found it. Bad search I had previously. I will address the Line 275 in 1010fad
|
I'm on mobile, so not sure. I just saw that one right above the line you changed when looking at the diff. I can help take a look over the code to find them tomorrow 👍 |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
647bdd1
to
9e240a5
Compare
e7b53e3
to
35880d6
Compare
7b8de6b
to
36618af
Compare
Continuation of #908 (comment):
I ran the GH actions on my forked repository and here are the results for all the commits: |
@dougwilson, have you got the time to take a look at this PR? |
I had the same issue :
Option 1) if (!res._implicitHeader) {
// Hack required until `express-<plugin>` get support for http2 (express-session)
res._implicitHeader = function(){ return; }; // Don't need, don't care
}
res.end(); This worked for me. Option 2) You should have something like: if (!res._header) {
res._implicitHeader()
} Needs to be replaced by: if (!res._header && res._implicitHeader) {
res._implicitHeader()
} This will skip the call for people using http2 or when Let me know if it worked for you guys. |
@dougwilson Not sure if you have the time to have a look at this PR again? |
9d2e29b
to
408229e
Compare
@@ -272,8 +272,8 @@ function session(options) { | |||
return ret; | |||
} | |||
|
|||
if (!res._header) { | |||
res._implicitHeader() | |||
if (typeof res.headersSent === 'boolean' ? !res.headersSent : !res._header) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's better to make it a function like in compression expressjs/compression#129
@@ -1371,6 +1381,25 @@ describe('session()', function(){ | |||
}) | |||
}); | |||
|
|||
describe('res._header patch', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this test makes sense.
Fixes #888
Replaced the usage of undocumented HTTP API with its implementation instead (bringing about some* http2 support).
There is no change to the existing behavior. This is similar to expressjs/compression#170.
Undocumented
res._implicitHeader
https://github.com/nodejs/node/blob/a8bc202d855cc7d14895db38a2ac09d1f873e803/lib/_http_server.js#L281Replaced with
res._implicitHeader
implementationhttps://github.com/nodejs/node/blob/a8bc202d855cc7d14895db38a2ac09d1f873e803/lib/_http_server.js#L282
Undocumented
res._header
https://github.com/nodejs/node/blob/93e0bf9abf350637d772bcce14a5d9527b733300/lib/_http_outgoing.js#L741
Replaced with
res.headersSent
https://github.com/nodejs/node/blob/93e0bf9abf350637d772bcce14a5d9527b733300/lib/_http_outgoing.js#L745
The changes do not require a semver major.
some* - This change may/may not provide full http2 support.