11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst http = require('http'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst server = http.createServer((req, res) => { 71cb0ef41Sopenharmony_ci res.setHeader('header1', 1); 81cb0ef41Sopenharmony_ci res.write('abc'); 91cb0ef41Sopenharmony_ci assert.throws( 101cb0ef41Sopenharmony_ci () => res.setHeader('header2', 2), 111cb0ef41Sopenharmony_ci { 121cb0ef41Sopenharmony_ci code: 'ERR_HTTP_HEADERS_SENT', 131cb0ef41Sopenharmony_ci name: 'Error', 141cb0ef41Sopenharmony_ci message: 'Cannot set headers after they are sent to the client' 151cb0ef41Sopenharmony_ci } 161cb0ef41Sopenharmony_ci ); 171cb0ef41Sopenharmony_ci res.end(); 181cb0ef41Sopenharmony_ci}); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciserver.listen(0, () => { 211cb0ef41Sopenharmony_ci http.get({ port: server.address().port }, () => { 221cb0ef41Sopenharmony_ci server.close(); 231cb0ef41Sopenharmony_ci }); 241cb0ef41Sopenharmony_ci}); 25