blob: 0ce984896d3aeaf286a6526a6fa00473615fc3e6 (
plain)
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
|
'use strict';
const common = require('../common');
const assert = require('assert');
const http = require('http');
const server = http.createServer().listen(0, connectToServer);
server.on('connection', common.mustCall((socket) => {
assert.throws(
() => {
socket.setEncoding('');
},
{
code: 'ERR_HTTP_SOCKET_ENCODING',
name: 'Error',
message: 'Changing the socket encoding is not ' +
'allowed per RFC7230 Section 3.'
}
);
socket.end();
}));
function connectToServer() {
const client = new http.Agent().createConnection(this.address().port, () => {
client.end();
}).on('end', () => server.close());
}
|