1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4 5const http = require('http'); 6const OutgoingMessage = http.OutgoingMessage; 7 8{ 9 const msg = new OutgoingMessage(); 10 assert.strictEqual(msg.writableObjectMode, false); 11} 12 13{ 14 const msg = new OutgoingMessage(); 15 assert(msg.writableHighWaterMark > 0); 16} 17 18{ 19 const server = http.createServer(common.mustCall(function(req, res) { 20 const hwm = req.socket.writableHighWaterMark; 21 assert.strictEqual(res.writableHighWaterMark, hwm); 22 23 assert.strictEqual(res.writableLength, 0); 24 res.write(''); 25 const len = res.writableLength; 26 res.write('asd'); 27 assert.strictEqual(res.writableLength, len + 8); 28 res.end(); 29 res.on('finish', common.mustCall(() => { 30 assert.strictEqual(res.writableLength, 0); 31 server.close(); 32 })); 33 })); 34 35 server.listen(0); 36 37 server.on('listening', common.mustCall(function() { 38 const clientRequest = http.request({ 39 port: server.address().port, 40 method: 'GET', 41 path: '/' 42 }); 43 clientRequest.end(); 44 })); 45} 46 47{ 48 const msg = new OutgoingMessage(); 49 msg._implicitHeader = function() {}; 50 assert.strictEqual(msg.writableLength, 0); 51 msg.write('asd'); 52 assert.strictEqual(msg.writableLength, 7); 53} 54 55{ 56 const server = http.createServer((req, res) => { 57 res.end(); 58 server.close(); 59 }); 60 61 server.listen(0); 62 63 server.on('listening', common.mustCall(() => { 64 const req = http.request({ 65 port: server.address().port, 66 method: 'GET', 67 path: '/' 68 }); 69 70 assert.strictEqual(req.path, '/'); 71 assert.strictEqual(req.method, 'GET'); 72 assert.strictEqual(req.host, 'localhost'); 73 assert.strictEqual(req.protocol, 'http:'); 74 req.end(); 75 })); 76} 77