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

doc: fix improper http.get sample code in http.markdown #4263

Closed
wants to merge 1 commit into from
Closed

doc: fix improper http.get sample code in http.markdown #4263

wants to merge 1 commit into from

Conversation

hidekiy
Copy link
Contributor

@hidekiy hidekiy commented Dec 13, 2015

I fixed improper sample code that will potentially hang up around http agent.
This is equals to nodejs/node-v0.x-archive#25471
Related issue is nodejs/node-v0.x-archive#8443

@hidekiy hidekiy changed the title Fix improper http.get sample code in http.markdown doc: fix improper http.get sample code in http.markdown Dec 13, 2015
@JungMinu JungMinu added the doc Issues and PRs related to the documentations. label Dec 13, 2015
@mscdex mscdex added the http Issues or PRs related to the http subsystem. label Dec 13, 2015
@rvagg
Copy link
Member

rvagg commented Dec 14, 2015

lgtm

@jasnell
Copy link
Member

jasnell commented Dec 14, 2015

LGTM

@MylesBorins
Copy link
Contributor

LGTM

Any idea how this commit vanished if it landed in nodejs/node-v0.x-archive@6671efa

edit:

LGTM pending until #4263 (comment) is responded to

@rvagg
Copy link
Member

rvagg commented Dec 14, 2015

@thealphanerd I wondered the same and assumed it was just something that got missed in convergence. Perhaps it was sitting on master in joyent/node and never made it to v0.12 which is what we focused on when we converged codebases? @jasnell do you have any more context on this?

@@ -966,6 +966,8 @@ Example:

http.get("http://www.google.com/index.html", function(res) {
console.log("Got response: " + res.statusCode);
// consume response body
res.resume();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be above console.log as seen in @chrisdickinson's original example?

might make sense to have the response enter flowing mode before accessing it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's necessary, statusCode is a property that exists when the function is called and isn't attached to the streaming nature of res in any way (beyond this point at least). I'm more concerned with the lack lack of information on what res.resume() does but explaining it here, even "enter flowing mode", is going to detract from the point of the example and likely take up too much additional space.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I dug a bit further into this. The response in the callback is an instance of http.IncomingMessage... and finding that out was not exactly obvious. http.IncomingMessage implements the Readable stream interface, which is where it inherits .resume from.

Quite a bit of digging is necessary to find out what this function does. While it may not make sense to duplicate documentation, perhaps we can find a better way to discover inherited properties

Any thoughts @nodejs/documentation?

If there is an interest in this I'll move it to a separate issue to avoid derailing this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. IncomingMessage would probably better be HTTPMessage.

@jasnell
Copy link
Member

jasnell commented Dec 14, 2015

Nope. Likely was just missed. Good catch.
On Dec 13, 2015 7:08 PM, "Rod Vagg" notifications@github.com wrote:

@thealphanerd https://github.com/TheAlphaNerd I wondered the same and
assumed it was just something that got missed in convergence. Perhaps it
was sitting on master in joyent/node and never made it to v0.12 which is
what we focused on when we converged codebases? @jasnell
https://github.com/jasnell do you have any more context on this?


Reply to this email directly or view it on GitHub
#4263 (comment).

@rvagg
Copy link
Member

rvagg commented Dec 14, 2015

As per last in-line comment, I'm +1 on merging this as is. It should go in to master, v4.x-staging and v0.12-staging I believe.

Thanks for catching this @hidekiy, I believe the original commit should have been your first ever commit to Node core but it got lost in the convergence fray, sorry about that. Welcome on board now though!

@hidekiy
Copy link
Contributor Author

hidekiy commented Dec 14, 2015

Thanks for reviewing. It is very helpful to me.
I'm looking forward to be merged and released.

@jasnell
Copy link
Member

jasnell commented Dec 14, 2015

LGTM

@thealphanerd ... is your LGTM still pending or are you ok with this going ahead and landing? If there are additional improvements that can be made they can be done separately

@MylesBorins
Copy link
Contributor

I am cool with this landing, I'll open another issue for the outstanding improvements

jasnell pushed a commit that referenced this pull request Dec 14, 2015
Refs: nodejs/node-v0.x-archive#25471
Refs: nodejs/node-v0.x-archive#8443
PR-URL: #4263
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell
Copy link
Member

jasnell commented Dec 14, 2015

Landed in c6efd53

@jasnell jasnell closed this Dec 14, 2015
cjihrig pushed a commit that referenced this pull request Dec 15, 2015
Refs: nodejs/node-v0.x-archive#25471
Refs: nodejs/node-v0.x-archive#8443
PR-URL: #4263
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@rvagg rvagg mentioned this pull request Dec 17, 2015
MylesBorins pushed a commit that referenced this pull request Dec 30, 2015
Refs: nodejs/node-v0.x-archive#25471
Refs: nodejs/node-v0.x-archive#8443
PR-URL: #4263
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 19, 2016
Refs: nodejs/node-v0.x-archive#25471
Refs: nodejs/node-v0.x-archive#8443
PR-URL: #4263
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Jan 19, 2016
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
Refs: nodejs/node-v0.x-archive#25471
Refs: nodejs/node-v0.x-archive#8443
PR-URL: nodejs#4263
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants