-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-http-outgoing-properties.js
59 lines (50 loc) · 1.38 KB
/
test-http-outgoing-properties.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict';
const common = require('../common');
const assert = require('assert');
const http2= require('http2');
/*
const OutgoingMessage = http.OutgoingMessage;
{
const msg = new OutgoingMessage();
assert.strictEqual(msg.writableObjectMode, false);
}
{
const msg = new OutgoingMessage();
assert(msg.writableHighWaterMark > 0);
}
*/
{
const server = http2.createServer(common.mustCall(function(req, res) {
const hwm = req.socket.writableHighWaterMark;
assert.strictEqual(res.writableHighWaterMark, hwm);
assert.strictEqual(res.writableLength, 0);
res.write('');
const len = res.writableLength;
res.write('asd');
assert.strictEqual(res.writableLength, len + 8);
res.end();
res.on('finish', common.mustCall(() => {
assert.strictEqual(res.writableLength, 0);
server.close();
}));
}));
server.listen(0);
server.on('listening', common.mustCall(function() {
const client = http2.connect('http://localhost:' + server.address().port);
const clientRequest = client.request();
clientRequest.on('data', () => {});
clientRequest.on('end', common.mustCall(() => {
clientRequest.close();
client.close();
}));
}));
}
/*
{
const msg = new OutgoingMessage();
msg._implicitHeader = function() {};
assert.strictEqual(msg.writableLength, 0);
msg.write('asd');
assert.strictEqual(msg.writableLength, 7);
}
*/