diff options
author | Robert Nagy <ronagy@icloud.com> | 2019-08-06 15:46:34 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-08-09 15:55:35 -0700 |
commit | c065773cc56080b48ff4e29822152679f7db5573 (patch) | |
tree | 608105d4c6992a1c6eefc9ad63b9adbf5ca3f339 /lib | |
parent | 53e467db24310a09772cd71fb6616239e950dd72 (diff) | |
download | android-node-v8-c065773cc56080b48ff4e29822152679f7db5573.tar.gz android-node-v8-c065773cc56080b48ff4e29822152679f7db5573.tar.bz2 android-node-v8-c065773cc56080b48ff4e29822152679f7db5573.zip |
http: buffer writes even while no socket assigned
PR-URL: https://github.com/nodejs/node/pull/29019
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_http_outgoing.js | 4 | ||||
-rw-r--r-- | lib/internal/streams/state.js | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index ef7c8c6577..e10f068f32 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -23,6 +23,7 @@ const { Object, ObjectPrototype } = primordials; +const { getDefaultHighWaterMark } = require('internal/streams/state'); const assert = require('internal/assert'); const Stream = require('stream'); const internalUtil = require('internal/util'); @@ -51,6 +52,7 @@ const { } = require('internal/errors'); const { validateString } = require('internal/validators'); +const HIGH_WATER_MARK = getDefaultHighWaterMark(); const { CRLF, debug } = common; const kIsCorked = Symbol('isCorked'); @@ -277,7 +279,7 @@ function _writeRaw(data, encoding, callback) { this.outputData.push({ data, encoding, callback }); this.outputSize += data.length; this._onPendingData(data.length); - return false; + return this.outputSize < HIGH_WATER_MARK; } diff --git a/lib/internal/streams/state.js b/lib/internal/streams/state.js index c2fa2d364c..a3f5e67286 100644 --- a/lib/internal/streams/state.js +++ b/lib/internal/streams/state.js @@ -9,6 +9,10 @@ function highWaterMarkFrom(options, isDuplex, duplexKey) { isDuplex ? options[duplexKey] : null; } +function getDefaultHighWaterMark(objectMode) { + return objectMode ? 16 : 16 * 1024; +} + function getHighWaterMark(state, options, duplexKey, isDuplex) { const hwm = highWaterMarkFrom(options, isDuplex, duplexKey); if (hwm != null) { @@ -20,9 +24,10 @@ function getHighWaterMark(state, options, duplexKey, isDuplex) { } // Default value - return state.objectMode ? 16 : 16 * 1024; + return getDefaultHighWaterMark(state.objectMode); } module.exports = { - getHighWaterMark + getHighWaterMark, + getDefaultHighWaterMark }; |