| 398 | |
| 399 | OutgoingMessage.prototype._writeRaw = _writeRaw; |
| 400 | function _writeRaw(data, encoding, callback, size) { |
| 401 | const conn = this[kSocket]; |
| 402 | if (conn?.destroyed) { |
| 403 | // The socket was destroyed. If we're still trying to write to it, |
| 404 | // then we haven't gotten the 'close' event yet. |
| 405 | return false; |
| 406 | } |
| 407 | |
| 408 | if (typeof encoding === 'function') { |
| 409 | callback = encoding; |
| 410 | encoding = null; |
| 411 | } |
| 412 | |
| 413 | if (conn && conn._httpMessage === this && conn.writable) { |
| 414 | // There might be pending data in the this.output buffer. |
| 415 | if (this.outputData.length) { |
| 416 | this._flushOutput(conn); |
| 417 | } |
| 418 | // Directly write to socket. |
| 419 | return conn.write(data, encoding, callback); |
| 420 | } |
| 421 | // Buffer, as long as we're not destroyed. |
| 422 | this.outputData.push({ data, encoding, callback }); |
| 423 | this.outputSize += data.length; |
| 424 | this._onPendingData(data.length); |
| 425 | return this.outputSize < this[kHighWaterMark]; |
| 426 | } |
| 427 | |
| 428 | |
| 429 | OutgoingMessage.prototype._storeHeader = _storeHeader; |