-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
[JSConf CN Code&Learn] Replace the string concatenation with template literals #14284
Conversation
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 think this changes the string. First, \r\n
is now just \n
. Second, spaces are added at the start of lines (that probably invalidate the http headers).
How about something more like this?:
socket.write(`HTTP/1.1 101 Ok${CRLF}` +
`Connection: Upgrade${CRLF}` +
`Upgrade: Test${CRLF}${CRLF}` +
'head');
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.
LGTM if CI is green
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.
Most other files just use \r\n
explicitly. I'd actually prefer that, but LGTM either way.
大部分其它HTTP的测试都直接写\r\n
。我觉得那样会更直截了当一些,但是不管怎么说都 LGTM。
@Trott PTAL |
Lone CI failure is unrelated to this change. CI is effectively green. This seems trivial enough that if someone wanted to land it before the 72 hour window, that would be fine IMO. |
'Upgrade: Test' + CRLF + CRLF + 'head'); | ||
socket.write(`HTTP/1.1 101 Ok${CRLF}` + | ||
`Connection: Upgrade${CRLF}` + | ||
`Upgrade: Test${CRLF}${CRLF}` + |
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.
the CRLF
is a bit pointless here. I'd just replace it with \r\n
literals and avoid the template string entirely.
PR-URL: nodejs#14284 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Landed in 66a6a15. Thanks for the contribution! 🎉 |
PR-URL: #14284 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
PR-URL: #14284 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
PR-URL: #14284 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
PR-URL: #14284 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
PR-URL: #14284 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
[JSConf CN Code&Learn]
Replace string concatenation in test /parallel/test-http-upgrade-client2.js with template literals.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
no.
Just update tests.