-
Notifications
You must be signed in to change notification settings - Fork 30k
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
http: enable setHeader for call chaining #35924
Conversation
Review requested:
|
The targeted subsystem can just be |
c8fa3aa
to
345fc6c
Compare
Can you please add a test? |
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'm fine with the test file as is but it could be simplified to something like
'use strict';
require('../common');
const assert = require('assert');
const { ServerResponse } = require('http');
const response = new ServerResponse({
method: 'GET',
httpVersionMajor: 1,
httpVersionMinor: 1
});
assert.strictEqual(response.setHeader('foo', 'bar'), response);
or just a single assertion like the one above in an already existing test where response.setHeader()
is used.
There is no need to start a server and chaining is a logical consequence of returning the same object.
5984558
to
3880ce6
Compare
Nit on the commit message. Maybe this is a little more clear?: |
Will this automatically add this for |
3880ce6
to
be03927
Compare
@Trott - This behavior will be added to the |
Benchmark results show a small performance hit in some cases. Probably acceptable? @nodejs/http
|
is there anything pending on this PR? if yes let me know . |
Landed in dedd061 |
Make `response.setHeader` return the response object itself so that multiple header setting can be chained. Fixes: #33148 PR-URL: #35924 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Rich Trott <[email protected]>
PR-URL: #36435 Notable changes: * child_processes: * add AbortSignal support (Benjamin Gruenbaum) (#36308) * deps: * update ICU to 68.1 (Michaël Zasso) (#36187) * events: * support signal in EventTarget (Benjamin Gruenbaum) (#36258) * graduate Event, EventTarget, AbortController (James M Snell) (#35949) * http: * enable call chaining with setHeader() (pooja d.p) (#35924) * module: * add isPreloading indicator (James M Snell) (#36263) * stream: * support abort signal (Benjamin Gruenbaum) (#36061) * add FileHandle support to Read/WriteStream (Momtchil Momtchev) (#35922) * worker: * add experimental BroadcastChannel (James M Snell) (#36271)
Make `response.setHeader` return the response object itself so that multiple header setting can be chained. Fixes: nodejs#33148 PR-URL: nodejs#35924 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Rich Trott <[email protected]>
PR-URL: #36435 Notable changes: * child_processes: * add AbortSignal support (Benjamin Gruenbaum) (#36308) * deps: * update ICU to 68.1 (Michaël Zasso) (#36187) * events: * support signal in EventTarget (Benjamin Gruenbaum) (#36258) * graduate Event, EventTarget, AbortController (James M Snell) (#35949) * http: * enable call chaining with setHeader() (pooja d.p) (#35924) * module: * add isPreloading indicator (James M Snell) (#36263) * stream: * support abort signal (Benjamin Gruenbaum) (#36061) * add FileHandle support to Read/WriteStream (Momtchil Momtchev) (#35922) * worker: * add experimental BroadcastChannel (James M Snell) (#36271)
PR-URL: #36435 Notable changes: * child_processes: * add AbortSignal support (Benjamin Gruenbaum) (#36308) * deps: * update ICU to 68.1 (Michaël Zasso) (#36187) * events: * support signal in EventTarget (Benjamin Gruenbaum) (#36258) * graduate Event, EventTarget, AbortController (James M Snell) (#35949) * http: * enable call chaining with setHeader() (pooja d.p) (#35924) * module: * add isPreloading indicator (James M Snell) (#36263) * stream: * support abort signal (Benjamin Gruenbaum) (#36061) * add FileHandle support to Read/WriteStream (Momtchil Momtchev) (#35922) * worker: * add experimental BroadcastChannel (James M Snell) (#36271)
Make `response.setHeader` return the response object itself so that multiple header setting can be chained. Fixes: #33148 PR-URL: #35924 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ricky Zhou <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Make
response.setHeader
return the response object itselfso that multiple header setting can be chained.
Fixes: #33148
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes