response的数据
1 // 2 require('http').createServer((request, response)=>{ 3 //1. 响应行 4 //1-1 响应状态码 5 response.statusCode = 200; 6 response.statusCode = 404; 7 response.statusCode = 500; 8 response.statusCode = 999; 9 //1-2 响应状态字符串 10 response.statusMessage = "HAHA"; 11 //2. 响应头 text/html 告知客户端响应体的类型 charset 设置响应体的字符集 12 response.setHeader('Content-type','text/html;charset=utf-8'); 13 response.setHeader("ceshi","this is a test"); 14 //3. 响应体 15 // write 16 // end 17 response.write("身无彩凤双飞翼"); 18 response.write("心有灵犀一点通"); 19 response.end(); //必须写的 20 // response.end('秀林真秀'); // 响应 HTML,CSS,JavaScript 21 }).listen(8000,()=>{ 22 console.log("服务启动 8000 端口监听中....."); 23 })