http2: Http2ServerResponse.end()
should always return self
PR-URL: https://github.com/nodejs/node/pull/24346 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
2a7da11ed8
commit
90fdf1b0d3
@ -648,7 +648,7 @@ class Http2ServerResponse extends Stream {
|
|||||||
|
|
||||||
if ((state.closed || state.ending) &&
|
if ((state.closed || state.ending) &&
|
||||||
state.headRequest === stream.headRequest) {
|
state.headRequest === stream.headRequest) {
|
||||||
return false;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof chunk === 'function') {
|
if (typeof chunk === 'function') {
|
||||||
|
@ -60,6 +60,34 @@ const {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Http2ServerResponse.end should return self after end
|
||||||
|
const server = createServer(mustCall((request, response) => {
|
||||||
|
strictEqual(response, response.end());
|
||||||
|
strictEqual(response, response.end());
|
||||||
|
server.close();
|
||||||
|
}));
|
||||||
|
server.listen(0, mustCall(() => {
|
||||||
|
const { port } = server.address();
|
||||||
|
const url = `http://localhost:${port}`;
|
||||||
|
const client = connect(url, mustCall(() => {
|
||||||
|
const headers = {
|
||||||
|
':path': '/',
|
||||||
|
':method': 'GET',
|
||||||
|
':scheme': 'http',
|
||||||
|
':authority': `localhost:${port}`
|
||||||
|
};
|
||||||
|
const request = client.request(headers);
|
||||||
|
request.setEncoding('utf8');
|
||||||
|
request.on('end', mustCall(() => {
|
||||||
|
client.close();
|
||||||
|
}));
|
||||||
|
request.end();
|
||||||
|
request.resume();
|
||||||
|
}));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Http2ServerResponse.end can omit encoding arg, sets it to utf-8
|
// Http2ServerResponse.end can omit encoding arg, sets it to utf-8
|
||||||
const server = createServer(mustCall((request, response) => {
|
const server = createServer(mustCall((request, response) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user