Repository navigation
http2: trailers or response to be emitted? #41251
Copy link
Copy link
Closed as not planned
Labels
http2Issues and PRs related to the http2 subsystem.Issues and PRs related to the http2 subsystem.linuxIssues and PRs related to the Linux platform.Issues and PRs related to the Linux platform.
Description
Version
v17.3.0
Platform
Linux pop-os 5.15.5-76051505-generic #202111250933~1638201579~21.04~09f1aa7-Ubuntu SMP Tue Nov 30 02: x86_64 x86_64 x86_64 GNU/Linux
Subsystem
http2
What steps will reproduce the bug?
const http2 = require('http2');
const server = http2.createServer((request, response) => {
response.writeContinue();
response.end(); // Make it end('') and it emits `response` instead
});
server.listen(() => {
const { port } = server.address();
const session = http2.connect(`http://localhost:${port}`);
const request = session.request({
':path': '/',
':method': 'GET',
});
request.on('response', (headers) => {
console.log('got response', headers);
});
request.on('headers', () => {
console.log('got headers');
});
request.on('trailers', (trailers) => {
console.log('got trailers', trailers);
});
request.end();
request.resume();
request.on('end', () => {
session.close();
server.close();
});
});How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
got headers
got response [Object: null prototype] {
':status': 200,
date: 'Mon, 20 Dec 2021 08:27:48 GMT',
[Symbol(nodejs.http2.sensitiveHeaders)]: []
}What do you see instead?
got headers
+got trailers [Object: null prototype] {
':status': 200,
date: 'Mon, 20 Dec 2021 08:27:48 GMT',
[Symbol(nodejs.http2.sensitiveHeaders)]: []
}Additional information
I'm not sure if this is the expected behavior. HTTP/1 for comparison (trailers are empty):
const http = require('http');
const server = http.createServer((request, response) => {
response.writeContinue();
response.end();
});
server.listen(() => {
const { port } = server.address();
const request = http.get(`http://localhost:${port}`, response => {
response.resume();
response.on('end', () => {
console.log(response.trailers, response.rawTrailers);
server.close();
});
});
request.on('information', () => {
console.log('information');
});
});information
{} []
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
http2Issues and PRs related to the http2 subsystem.Issues and PRs related to the http2 subsystem.linuxIssues and PRs related to the Linux platform.Issues and PRs related to the Linux platform.
Activity
szmarczak commentedon Dec 20, 2021
Relevant RFC: https://datatracker.ietf.org/doc/html/rfc7540#section-8.1
szmarczak commentedon Dec 20, 2021
Wireshark
trailersevent:responseevent:szmarczak commentedon Dec 20, 2021
👍
szmarczak commentedon Dec 20, 2021
Following: then
I think it should emit
trailersinstead ofresponse.Wireshark
MoonBall commentedon Jan 5, 2022
I think HTTP/2 should be consistent with HTTP/1 behavior. About the above case, they shouldn't emit
trailersevent.szmarczak commentedon Jan 5, 2022
@MoonBall Please note that in the original issue it emits
trailersinstead ofresponse. I'd prefer consistent behavior over making it look like HTTP/1.MoonBall commentedon Jan 5, 2022
In the original issue I think it should emit
response. I would like to dig into itaduh95 commentedon May 11, 2024
Duplicate of #38258