@ -136,36 +136,32 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback) {
OutgoingMessage . prototype . _ writeRaw = _ writeRaw ;
function _ writeRaw ( data , encoding , callback ) {
const conn = this . connection ;
if ( conn && conn . destroyed ) {
// The socket was destroyed. If we're still trying to write to it,
// then we haven't gotten the 'close' event yet.
return false ;
}
if ( typeof encoding === 'function' ) {
callback = encoding ;
encoding = null ;
}
var connection = this . connection ;
if ( connection &&
connection . _ httpMessage === this &&
connection . writable &&
! connection . destroyed ) {
if ( conn && conn . _ httpMessage === this && conn . writable && ! conn . destroyed ) {
// There might be pending data in the this.output buffer.
var outputLength = this . output . length ;
if ( outputLength > 0 ) {
this . _ flushOutput ( connection ) ;
} else if ( data . length === 0 ) {
if ( this . output . length ) {
this . _ flushOutput ( conn ) ;
} else if ( ! data . length ) {
if ( typeof callback === 'function' )
process . nextTick ( callback ) ;
return true ;
}
// Directly write to socket.
return connection . write ( data , encoding , callback ) ;
} else if ( connection && connection . destroyed ) {
// The socket was destroyed. If we're still trying to write to it,
// then we haven't gotten the 'close' event yet.
return false ;
} else {
// buffer, as long as we're not destroyed.
return this . _ buffer ( data , encoding , callback ) ;
return conn . write ( data , encoding , callback ) ;
}
// Buffer, as long as we're not destroyed.
return this . _ buffer ( data , encoding , callback ) ;
}
@ -477,6 +473,7 @@ Object.defineProperty(OutgoingMessage.prototype, 'headersSent', {
} ) ;
const crlf_buf = Buffer . from ( '\r\n' ) ;
OutgoingMessage . prototype . write = function write ( chunk , encoding , callback ) {
if ( this . finished ) {
var err = new Error ( 'write after end' ) ;
@ -583,9 +580,6 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
}
} ;
const crlf_buf = Buffer . from ( '\r\n' ) ;
function onFinish ( outmsg ) {
outmsg . emit ( 'finish' ) ;
}