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 — doc: fix misleading sentence in http.md by lpinca · Pull Request #26465 · nodejs/node

Conversation

@lpinca

@lpinca lpinca commented Mar 6, 2019

Copy link
Copy Markdown
Member

Calling response.end(data) is not 100% equivalent to calling
response.write(data) followed by response.end().

Fixes: #26005

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • 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 commented Mar 6, 2019

Copy link
Copy Markdown
Collaborator

@lpinca build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/2778/pipeline

All reactions

Sorry, something went wrong.

Uh oh!

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

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to Node.js documentation. http Issues and PRs related to the http subsystem. labels Mar 6, 2019
BridgeAR
BridgeAR previously approved these changes Mar 6, 2019
View reviewed changes
@BridgeAR BridgeAR added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Mar 6, 2019
ZYSzys
ZYSzys approved these changes Mar 6, 2019
View reviewed changes
vsemozhetbyt
vsemozhetbyt reviewed Mar 6, 2019
View reviewed changes
Comment thread doc/api/http.md Outdated

@vsemozhetbyt vsemozhetbyt Mar 6, 2019

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.

Nit:

Suggested change
`chunked`, otherwise the `Transfer-Encoding` header is replaced by the
`'chunked'`, otherwise the `Transfer-Encoding` header is replaced by the

Sorry, something went wrong.

Uh oh!

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

All reactions

@Trott Trott Mar 6, 2019

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.

Optional suggestion: Change the comma to a period and make the Otherwise clause its own sentence.

Sorry, something went wrong.

Uh oh!

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

All reactions
@richardlau

richardlau commented Mar 6, 2019

Copy link
Copy Markdown
Member

Commit message has misspelled sentence.

All reactions

Sorry, something went wrong.

Uh oh!

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

@lpinca
lpinca force-pushed the gh-26005 branch from ebb49fa to 286f7ab Compare March 6, 2019 16:31
sam-github
sam-github reviewed Mar 6, 2019
View reviewed changes
Comment thread doc/api/http.md Outdated

@sam-github sam-github Mar 6, 2019

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.

I think this leaves one case undescribed: response.write(data); response.end(data)

Also, while accurate, so an improvement, I think its too low level, it doesn't give any idea why its done this way. And if you knew why, then you wouldn't need the docs.

I'd suggest that the .write() docs be modified to say that because .write() can be called multiple times, the size of the entire response (or request, I suspect these docs apply to both req and response) cannot be known when .write() is called, so HTTP will use chunked transfer encoding, and there will not be a content-size header.

In .end(), I'd say that if .write() has not previously been called, the total size is known (zero, or the size of the data arg), so node.js doesn't have to (and won't) use chunked transfer encoding, and it will write a content-length header. In other cases, since chunked transfer has already begun, any data provided to .end() will be transferred as a chunk.

^--- I think this is accurate, and describes why this is, and makes this seem less like a weird gotcha, and more like a feature: that if you have one large chunk that can be written in a single call to .end(), you can cause the content-size to be set and chunked mode not to be used. I'm not sure if it applies equally to the writing of requests, and the writing of responponses... but it should!

Sorry, something went wrong.

Uh oh!

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

All reactions

@lpinca lpinca Mar 6, 2019 •
edited
Loading

Uh oh!

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

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.

I only wanted to address the misleading sentence quoted in #26005 and not describe chunk mode. This is also not 100% accurate as the user could explicitly specify Content-Length disabling the default chunked mode. Perhaps it's simpler to just remove that sentence?

Sorry, something went wrong.

Uh oh!

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

All reactions

@sam-github sam-github Mar 6, 2019

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.

It would be nice to have the info about how explicitly setting the header changes things. Basically, that Node.js has good support for chunked mode (unlike a number of crappy HTTP APIs I've come across), is a wonderful feature, its a shame we don't document it better.

Your comment above makes me wonder if your proposed text is accurate/complete, doesn't it suffer the same problem?

For now, yes, I think rather than dumping in the detail you proposed, if you aren't up to a really comprehensive treatment, just changing "the same as" to "similar in effect to", or similar weasel words, might make the docs "not wrong", even though it still leaves streaming vs non-streaming mode undoced.

Sorry, something went wrong.

Uh oh!

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

All reactions

@lpinca lpinca Mar 6, 2019

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.

Your comment above makes me wonder if your proposed text is accurate/complete, doesn't it suffer the same problem?

Yes, I've added "the headers that are sent by default" to address that but I guess it's not clear.

I will change this tomorrow and use "similar" removing all the chunked mode info.
FWIW the request counterparts are slightly better documented.

Sorry, something went wrong.

Uh oh!

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

All reactions
@sam-github sam-github changed the title doc: fix misleading sentece in http.md doc: fix misleading sentence in http.md Mar 6, 2019
@sam-github

sam-github commented Mar 6, 2019

Copy link
Copy Markdown
Contributor

nit: I think a commit message of doc: describe when chunked mode is used would be more descriptive of the specific change being made.

All reactions

Sorry, something went wrong.

Uh oh!

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

jasnell
jasnell approved these changes Mar 7, 2019
View reviewed changes
@lpinca
doc: fix misleading sentence in http.md
f80563f
Calling `response.end(data)` is not 100% equivalent to calling
`response.write(data)` followed by `response.end()`.

Fixes: nodejs#26005
@lpinca
lpinca force-pushed the gh-26005 branch from 286f7ab to f80563f Compare March 7, 2019 08:33
@lpinca

lpinca commented Mar 7, 2019

Copy link
Copy Markdown
Member Author

Folks that approved this, PTAL, I've updated as per @sam-github suggestion.

All reactions

Sorry, something went wrong.

Uh oh!

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

@BridgeAR
BridgeAR dismissed their stale review March 7, 2019 08:47

Abstain

@BridgeAR

BridgeAR commented Mar 7, 2019

Copy link
Copy Markdown
Member

I would rather have a detailed information but I won't block this either.

All reactions

Sorry, something went wrong.

Uh oh!

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

@lpinca

lpinca commented Mar 7, 2019 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

It makes sense but I don't have the energy to update the docs as suggested in #26465 (comment) explaining how and when chunked mode is used, how to disable it, etc. especially due to all the nit picking that will come from that.

If that is preferred I would prefer it to be done by a native speaker.

sam-github 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.

@BridgeAR

BridgeAR commented Mar 12, 2019

Copy link
Copy Markdown
Member

What should be done here?

@jasnell PTAL

All reactions

Sorry, something went wrong.

Uh oh!

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

sam-github
sam-github approved these changes Mar 13, 2019
View reviewed changes
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Mar 13, 2019
@lpinca @BridgeAR
doc: fix misleading sentence in http.md
1706a2d
Calling `response.end(data)` is not 100% equivalent to calling
`response.write(data)` followed by `response.end()`.

PR-URL: nodejs#26465
Fixes: nodejs#26005
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
@BridgeAR

BridgeAR commented Mar 13, 2019

Copy link
Copy Markdown
Member

Landed in 1706a2d 🎉

All reactions

Sorry, something went wrong.

Uh oh!

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

@BridgeAR BridgeAR closed this Mar 13, 2019
@lpinca
lpinca deleted the gh-26005 branch March 13, 2019 15:47
BridgeAR pushed a commit that referenced this pull request Mar 14, 2019
@lpinca @BridgeAR
doc: fix misleading sentence in http.md
deb6826
Calling `response.end(data)` is not 100% equivalent to calling
`response.write(data)` followed by `response.end()`.

PR-URL: #26465
Fixes: #26005
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
@BridgeAR BridgeAR mentioned this pull request Mar 14, 2019
2019-03-14, Version 11.12.0 (Current) #26644
Merged
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Mar 14, 2019
@lpinca @BridgeAR
doc: fix misleading sentence in http.md
7309539
Calling `response.end(data)` is not 100% equivalent to calling
`response.write(data)` followed by `response.end()`.

PR-URL: nodejs#26465
Fixes: nodejs#26005
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
BridgeAR pushed a commit that referenced this pull request Mar 14, 2019
@lpinca @BridgeAR
doc: fix misleading sentence in http.md
b9cfaa3
Calling `response.end(data)` is not 100% equivalent to calling
`response.write(data)` followed by `response.end()`.

PR-URL: #26465
Fixes: #26005
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
BethGriggs pushed a commit that referenced this pull request Apr 16, 2019
@lpinca @BethGriggs
doc: fix misleading sentence in http.md
0a976ec
Calling `response.end(data)` is not 100% equivalent to calling
`response.write(data)` followed by `response.end()`.

PR-URL: #26465
Fixes: #26005
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
@BethGriggs BethGriggs mentioned this pull request May 1, 2019
v10.16.0 proposal #27514
Merged
This was referenced May 29, 2019
2019-05-28 Version 10.16.0 'Dubnium' (LTS) @BethGriggs beevelop/docker-android-nodejs#315
Closed
2019-05-28 Version 10.16.0 'Dubnium' (LTS) @BethGriggs beevelop/docker-android-nodejs#316
Closed
2019-05-28 Version 10.16.0 'Dubnium' (LTS) @BethGriggs beevelop/docker-android-nodejs#317
Closed
2019-05-28 Version 10.16.0 'Dubnium' (LTS) @BethGriggs beevelop/docker-android-nodejs#318
Closed
2019-05-28 Version 10.16.0 'Dubnium' (LTS) @BethGriggs beevelop/docker-android-nodejs#319
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Trott Trott Trott left review comments
@jasnell jasnell jasnell approved these changes
@ZYSzys ZYSzys ZYSzys approved these changes
@BridgeAR BridgeAR BridgeAR left review comments
+2 more reviewers
@vsemozhetbyt vsemozhetbyt vsemozhetbyt left review comments
@sam-github sam-github sam-github approved these changes
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

author ready PRs with CI started, the required approvals, and no outstanding review comments. doc Issues and PRs related to Node.js documentation. http Issues and PRs related to the http subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

doc(http): res.write(data) followed by res.end() is not actually equivalent to res.end(data)

Uh oh!

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

9 participants

@lpinca @nodejs-github-bot @richardlau @sam-github @BridgeAR @jasnell @Trott @vsemozhetbyt @ZYSzys
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.