11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci/** 41cb0ef41Sopenharmony_ci * This test covers http.Server({ ServerResponse }) option: 51cb0ef41Sopenharmony_ci * With ServerResponse option the server should use 61cb0ef41Sopenharmony_ci * the new class for creating res Object instead of the default 71cb0ef41Sopenharmony_ci * http.ServerResponse. 81cb0ef41Sopenharmony_ci */ 91cb0ef41Sopenharmony_ciconst common = require('../common'); 101cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciif (!common.hasCrypto) 131cb0ef41Sopenharmony_ci common.skip('missing crypto'); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst assert = require('assert'); 161cb0ef41Sopenharmony_ciconst http = require('http'); 171cb0ef41Sopenharmony_ciconst https = require('https'); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciclass MyServerResponse extends http.ServerResponse { 201cb0ef41Sopenharmony_ci status(code) { 211cb0ef41Sopenharmony_ci return this.writeHead(code, { 'Content-Type': 'text/plain' }); 221cb0ef41Sopenharmony_ci } 231cb0ef41Sopenharmony_ci} 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ciconst server = https.createServer({ 261cb0ef41Sopenharmony_ci key: fixtures.readKey('agent1-key.pem'), 271cb0ef41Sopenharmony_ci cert: fixtures.readKey('agent1-cert.pem'), 281cb0ef41Sopenharmony_ci ca: fixtures.readKey('ca1-cert.pem'), 291cb0ef41Sopenharmony_ci ServerResponse: MyServerResponse 301cb0ef41Sopenharmony_ci}, common.mustCall(function(req, res) { 311cb0ef41Sopenharmony_ci res.status(200); 321cb0ef41Sopenharmony_ci res.end(); 331cb0ef41Sopenharmony_ci})); 341cb0ef41Sopenharmony_ciserver.listen(); 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ciserver.on('listening', function makeRequest() { 371cb0ef41Sopenharmony_ci https.get({ 381cb0ef41Sopenharmony_ci port: this.address().port, 391cb0ef41Sopenharmony_ci rejectUnauthorized: false 401cb0ef41Sopenharmony_ci }, (res) => { 411cb0ef41Sopenharmony_ci assert.strictEqual(res.statusCode, 200); 421cb0ef41Sopenharmony_ci res.on('end', () => { 431cb0ef41Sopenharmony_ci server.close(); 441cb0ef41Sopenharmony_ci }); 451cb0ef41Sopenharmony_ci res.resume(); 461cb0ef41Sopenharmony_ci }); 471cb0ef41Sopenharmony_ci}); 48