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.
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 |
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 <luigipinca@gmail.com> Reviewed-By: Ricky Zhou <0x19951125@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
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.setHeaderreturn the response object itselfso that multiple header setting can be chained.
Fixes: #33148
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes