GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — https: allow url and options to be passed to https.request by rubys · Pull Request #22003 · nodejs/node

Conversation

@rubys

@rubys rubys commented Jul 27, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This completes #21616 by adding https which was inadvertently left out.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@nodejs-github-bot nodejs-github-bot added http Issues and PRs related to the http subsystem. https Issues and PRs related to the https subsystem. labels Jul 27, 2018
@mscdex

mscdex commented Jul 27, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I would prefer avoiding adding new (underscore-prefixed) functions to the prototype.

I believe this could be resolved at least by one of:

  • Making HttpsClientRequest have no additional methods and checking this.constructor === HttpsClientRequest
  • Allow passing a 4th option to ClientRequest that if not undefined, must be a private symbol indicating an https client request
  • Make the few changes needed to the original code in https to support both url and options

Also, I think the commit message should technically have an https: prefix?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina reviewed Jul 27, 2018
View reviewed changes
Comment thread lib/_http_client.js Outdated

@mcollina mcollina Jul 27, 2018

Copy link
Copy Markdown
Member

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 would avoid exposing those two directly. Maybe we should move them under a private Symbol?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rubys
https: allow url and options to be passed to https.request
9f8f5d9
@rubys
rubys force-pushed the https_url_options branch from 86109e4 to 9f8f5d9 Compare July 29, 2018 05:01
@rubys rubys changed the title http: allow url and options to be passed to https.request https: allow url and options to be passed to https.request Jul 29, 2018
mscdex
mscdex reviewed Jul 29, 2018
View reviewed changes
Comment thread lib/https.js
return new ClientRequest(options, cb);
args.unshift(options);

return new ClientRequest(...args);

@mscdex mscdex Jul 29, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

Last I checked, this was still significantly slower in V8 I think?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rubys rubys Jul 29, 2018

Copy link
Copy Markdown
Member Author

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.

Fixed in Node 8.3? See https://github.com/davidmarkclements/v8-perf

Here’s the takeaway: if we want to write performant code around processing function inputs as an array (which in my experience seems fairly common), then in Node 8.3 and up we should use the spread operator.

Responding to your original suggestions:

Making HttpsClientRequest have no additional methods and checking this.constructor === HttpsClientRequest

The issue is that without additional methods, it never would be called... unless we duplicated the entire constructor.

Allow passing a 4th option to ClientRequest that if not undefined, must be a private symbol indicating an https client request

This will impact the ability to add future arguments. And we are currently dealing with three arguments, all optional...

Make the few changes needed to the original code in https to support both url and options

I went this way for now.

The other option:

Maybe we should move them under a private Symbol?

This is clean and would work. The symbols would need to be exported by lib/_http_client.js

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mcollina mcollina Jul 29, 2018

Copy link
Copy Markdown
Member

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.

This is clean and would work. The symbols would need to be exported by lib/_http_client.js

I would prefer it. Unfortunately there is a lot of monkey patching around core methods, and I would prefer this would be as private as possible. I would not block this for it.

If you feel strongly about going _, then ok.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rubys rubys Jul 29, 2018

Copy link
Copy Markdown
Member Author

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.

@mcollina I'm not following.... in particular, I'm not sure what 'it' refers to.

Should I go back to the previous approach of subclassing ClientRequest for https, and introducing two new methods, this time with the method names being Symbols? My thoughts are that that approach is more understandable and maintainable.

Or would you prefer the current approach which duplicates a bit of code, but doesn't introduce any new methods. My thoughts are that approach is more private.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mcollina mcollina Jul 29, 2018

Copy link
Copy Markdown
Member

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 was actually commenting on some old code. The current approach is fine. LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mscdex mscdex Jul 29, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

Making HttpsClientRequest have no additional methods and checking this.constructor === HttpsClientRequest

The issue is that without additional methods, it never would be called... unless we duplicated the entire constructor.

@rubys I'm not sure what you mean, HttpsClientRequest would extend from ClientRequest and be empty itself (no explicit constructor or additional methods). Then inside ClientRequest, checking this.constructor like:

var defaultAgent = options._defaultAgent ||
                   (this.constructor === https[ClientRequestSym]
                    ? https.globalAgent : Agent.globalAgent);

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rubys rubys Jul 29, 2018

Copy link
Copy Markdown
Member Author

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.

@McDex Fair point, but making that work would involve a circular require.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mscdex mscdex Jul 29, 2018

Copy link
Copy Markdown
Contributor

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.

@rubys Not if it's lazy loaded.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mcollina
mcollina approved these changes Jul 29, 2018
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mcollina

mcollina commented Jul 29, 2018

Copy link
Copy Markdown
Member

CI: https://ci.nodejs.org/job/node-test-pull-request/16066/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Jul 30, 2018
@Trott

Trott commented Jul 30, 2018

Copy link
Copy Markdown
Member

Resume Build: https://ci.nodejs.org/job/node-test-pull-request/16071/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Jul 30, 2018
View reviewed changes
@Trott Trott removed the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Aug 1, 2018
@Trott

Trott commented Aug 1, 2018

Copy link
Copy Markdown
Member

I removed the author ready label because I'm not sure if the comments from @mscdex are blocking or if @rubys would want to address them first before landing regardless. Feel free to add the label back or to land the thing if I'm wrong. It's possible I'm being overly cautious.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rubys

rubys commented Aug 1, 2018

Copy link
Copy Markdown
Member Author

I believe that this is ready to land. @McDex and @mcollina had similar concerns on my first implementation and collectively provided four alternatives. I selected and implemented @McDex's third option, and @mcollina approved the approach.

What remains is side conversation as to whether @McDex's first suggestion could also be made to work (it could, but wouldn't be as clear/straightforward as the third suggestion, in my opinion). Assuming that @McDex is still comfortable with his third suggestion (he should be, he suggested it :-)), I think we are good to go.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mscdex

mscdex commented Aug 1, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I don't have a problem adding the missing code to https. My last comments were about a preferred way
for avoiding the code duplication.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Aug 1, 2018
@Trott

Trott commented Aug 1, 2018

Copy link
Copy Markdown
Member

@mscdex Just to make sure I'm understanding: You're OK with this landing without the lazy loading? That can be implemented in a subsequent PR or not at all and that's OK?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mscdex

mscdex commented Aug 1, 2018

Copy link
Copy Markdown
Contributor

@Trott My comment about the https lazy loading and constructor checking was one possible solution, one that would avoid the need to duplicate code. I am fine with either that or adding the missing code in https, which is what the PR does as of this writing.

Trott reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Aug 1, 2018

Copy link
Copy Markdown
Member

Landed in 19aa41c

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott closed this Aug 1, 2018
Trott pushed a commit to Trott/io.js that referenced this pull request Aug 1, 2018
@rubys @Trott
https: allow url and options to be passed to https.request
19aa41c
PR-URL: nodejs#22003
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@targos targos added backport-requested-v10.x and removed author ready PRs with CI started, the required approvals, and no outstanding review comments. labels Aug 1, 2018
@targos

targos commented Aug 1, 2018

Copy link
Copy Markdown
Member

This should be backported along with #21616

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

targos pushed a commit to targos/node that referenced this pull request Aug 2, 2018
@rubys @targos
https: allow url and options to be passed to https.request
0c748a4
PR-URL: nodejs#22003
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@targos targos mentioned this pull request Aug 2, 2018
[v10.x] http: allow url and options to be passed to http*.request and http*.get #21880
Closed
@targos targos added backported-to-v10.x and removed backport-requested-v10.x labels Aug 7, 2018
targos pushed a commit that referenced this pull request Aug 7, 2018
@rubys @targos
https: allow url and options to be passed to https.request
2bf9a4a
PR-URL: #22003
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>

Backport-PR-URL: #21880
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@rvagg rvagg mentioned this pull request Aug 13, 2018
Release proposal: v10.9.0 #22295
Merged
This was referenced Aug 16, 2018
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#230
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#215
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#231
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#216
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#232
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#217
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#233
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#218
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-android-nodejs#234
Closed
2018-08-15 Version 10.9.0 (Current) @rvagg beevelop/docker-nodejs#219
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@jasnell jasnell jasnell approved these changes
+1 more reviewer
@mscdex mscdex mscdex left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

http Issues and PRs related to the http subsystem. https Issues and PRs related to the https subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@rubys @mscdex @mcollina @Trott @targos @jasnell @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.