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

[JSConf CN Code&Learn] Replace the string concatenation with template literals #14284

Closed
wants to merge 2 commits into from

Conversation

HSUCHING
Copy link
Contributor

[JSConf CN Code&Learn]

Replace string concatenation in test /parallel/test-http-upgrade-client2.js with template literals.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

no.
Just update tests.

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Jul 16, 2017
@TimothyGu TimothyGu added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Jul 16, 2017
Copy link
Member

@Trott Trott left a 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');

@HSUCHING HSUCHING closed this Jul 16, 2017
@targos targos reopened this Jul 16, 2017
Copy link
Member

@Trott Trott left a 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

Copy link
Member

@TimothyGu TimothyGu left a 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。

@tniessen
Copy link
Member

@Trott PTAL

@vsemozhetbyt
Copy link
Contributor

@Trott
Copy link
Member

Trott commented Jul 17, 2017

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}` +
Copy link
Member

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.

Trott pushed a commit to Trott/io.js that referenced this pull request Jul 26, 2017
PR-URL: nodejs#14284
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
@Trott
Copy link
Member

Trott commented Jul 26, 2017

Landed in 66a6a15.

Thanks for the contribution! 🎉

@Trott Trott closed this Jul 26, 2017
addaleax pushed a commit that referenced this pull request Jul 27, 2017
PR-URL: #14284
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
@addaleax addaleax mentioned this pull request Aug 2, 2017
MylesBorins pushed a commit that referenced this pull request Aug 16, 2017
PR-URL: #14284
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Aug 16, 2017
MylesBorins pushed a commit that referenced this pull request Aug 16, 2017
PR-URL: #14284
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
MylesBorins pushed a commit that referenced this pull request Sep 3, 2017
PR-URL: #14284
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
MylesBorins pushed a commit that referenced this pull request Sep 5, 2017
PR-URL: #14284
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.