1'use strict';
2
3/**
4 * This test covers http.Server({ ServerResponse }) option:
5 * With ServerResponse option the server should use
6 * the new class for creating res Object instead of the default
7 * http.ServerResponse.
8 */
9const common = require('../common');
10const assert = require('assert');
11const http = require('http');
12
13class MyServerResponse extends http.ServerResponse {
14  status(code) {
15    return this.writeHead(code, { 'Content-Type': 'text/plain' });
16  }
17}
18
19const server = http.Server({
20  ServerResponse: MyServerResponse
21}, common.mustCall(function(req, res) {
22  res.status(200);
23  res.end();
24}));
25server.listen();
26
27server.on('listening', function makeRequest() {
28  http.get({ port: this.address().port }, (res) => {
29    assert.strictEqual(res.statusCode, 200);
30    res.on('end', () => {
31      server.close();
32    });
33    res.resume();
34  });
35});
36