-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-http-invalidheaderfield.js
66 lines (58 loc) · 1.23 KB
/
test-http-invalidheaderfield.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
60
61
62
63
64
65
66
'use strict';
const common = require('../common');
const assert = require('assert');
const EventEmitter = require('events');
const http2 = require('http2');
const ee = new EventEmitter();
let count = 2;
const server = http2.createServer(function(req, res) {
res.setHeader('testing_123', 123);
assert.throws(function() {
res.setHeader('testing 123', 123);
}, TypeError);
res.end('');
});
let client;
server.listen(0, function() {
client = http2.connect('http://localhost:' + this.address().port);
const req = client.request({
':path': '/world'
});
req.on('end', function() {
ee.emit('done');
req.close();
});
req.end();
/*
assert.throws(
function() {
const req2 = client.request({
'testing 123': 123
});
req2.on('end', common.mustNotCall(() => {
req2.close();
}));
req2.end();
},
function(err) {
ee.emit('done');
if (err instanceof TypeError) return true;
}
);
*/
// Should not throw.
const req3 = client.request({
'testing_123': 123
});
req3.on('end', () => {
ee.emit('done');
req3.close();
});
req.end();
});
ee.on('done', function() {
if (--count === 0) {
client.close();
server.close();
}
});