[JSConf CN Code&Learn] Replace the string concatenation with template literals #14284
[JSConf CN Code&Learn] Replace the string concatenation with template literals #14284HSUCHING wants to merge 2 commits intonodejs:masterfrom
Conversation
There was a problem hiding this comment.
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');
TimothyGu
left a comment
There was a problem hiding this comment.
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.
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.