Skip to content
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

http2: add bytesWritten test for Http2Stream #33162

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/parallel/test-http2-byteswritten-server.js
@@ -0,0 +1,28 @@
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const http2 = require('http2');

const http2Server = http2.createServer(common.mustCall(function(req, res) {
res.socket.on('finish', common.mustCall(() => {
assert(req.socket.bytesWritten > 0); // 1094
}));
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write(Buffer.from('1'.repeat(1024)));
res.end();
}));

http2Server.listen(0, common.mustCall(function() {
const URL = `http://localhost:${http2Server.address().port}`;
const http2client = http2.connect(URL, { protocol: 'http:' });
const req = http2client.request({ ':method': 'GET', ':path': '/' });
req.on('data', common.mustCall());
req.on('end', common.mustCall(function() {
http2client.close();
http2Server.close();
}));
req.end();
}));