doc: explain HTTP writeHead()'s fast path behavior#21289
doc: explain HTTP writeHead()'s fast path behavior#21289gireeshpunathil wants to merge 1 commit intonodejs:masterfrom
Conversation
|
@gireeshpunathil sadly an error occured when I tried to trigger a build :( |
|
Is this intended to be in the |
doc/api/http.md
Outdated
There was a problem hiding this comment.
This long line seems to break linting.
lpinca
left a comment
There was a problem hiding this comment.
LGTM with @vsemozhetbyt's nit addressed.
2526761 to
f429d40
Compare
|
that is interesting. I ran $ make lint-ci any idea why? Nevertheless, made the changes and pushed, please have a look. |
No, it is meant at |
|
@gireeshpunathil The |
|
@gireeshpunathil Currently, the first fragment is placed in the |
doc/api/http.md
Outdated
There was a problem hiding this comment.
This is inserted in an incorrect area or has the wrong links.
doc/api/http.md
Outdated
There was a problem hiding this comment.
are desired -> is desired?
doc/api/http.md
Outdated
There was a problem hiding this comment.
are desired -> is desired?
calling writeHead() into a Response object that has no headers already set causes getHeader() to return undefined, even if the header was set in the writeHead() function call. Explain this behavior as an optimiation as opposed to a bug. Fixes: nodejs#10354
749e155 to
c86df32
Compare
| called, it will directly write the supplied header values onto the network | ||
| channel without caching internally, and the [`response.getHeader()`][] on the | ||
| header will not yield the expected result. If progressive population of headers | ||
| is desired with potential future retrieval and modification, use |
There was a problem hiding this comment.
Is modification still possible after writeHead? Sounds to me like only retrieval is possible. Ditto below.
There was a problem hiding this comment.
@TimothyGu - yes, that is right: headers written through writeHead are not modifiable, and attempt to do so results in error Cannot set headers after they are sent to the client. Hence the suggestion to use setHeader() API for such cases. If the text is not conveying that let me know where and how can I fix it, thanks.
There was a problem hiding this comment.
Yeah, you wrote
If progressive population of headers is desired with potential future retrieval and modification, use …
It seemed to me that the bolded bit should perhaps be removed.
There was a problem hiding this comment.
sorry, missed this update. Sorry, I am missing your point:
#cat 10354.js
const h = require('http')
h.createServer((q, r) => {
r.setHeader('foo', 'bar')
r.setHeader('foo', 'new')
r.end()
}).listen(12000, () => {
const c = h.get('http://localhost:12000', (m) => {
console.log(m.headers)
})
})#node 10354.js
{ foo: 'new',
date: 'Thu, 21 Jun 2018 14:42:33 GMT',
connection: 'close',
'content-length': '0' }
setHeader() is indeed used for modification, and hence the text. Can you please clarify your point?
There was a problem hiding this comment.
Never mind, I see what this is trying to say now.
|
In the light of recent changes to the build process, what is the CI recommendation for doc changes? (sorry, I was not keeping track of the conversations) full CI (manual trigger) / lite CI (manual trigger) / do nothing - as the auto-CI said all checks have passed. |
|
answering my own question, I guess it is |
calling writeHead() into a Response object that has no headers already set causes getHeader() to return undefined, even if the header was set in the writeHead() function call. Explain this behavior as an optimiation as opposed to a bug. Fixes: #10354 PR-URL: #21289 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
|
landed as cbe307d |
calling writeHead() into a Response object that has no headers already set causes getHeader() to return undefined, even if the header was set in the writeHead() function call. Explain this behavior as an optimiation as opposed to a bug. Fixes: #10354 PR-URL: #21289 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
calling writeHead() into a Response object that has no headers already
set causes getHeader() to return undefined, even if the header was set
in the writeHead() function call. Explain this behavior as an
optimiation as opposed to a bug.
Fixes: #10354
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes