Skip to content

Commit

Permalink
net: use decodeStrings public API for writable stream
Browse files Browse the repository at this point in the history
Instead of using an undocumented underscore-prefixed property to
configure the writable stream instance to not encode strings as buffers,
use the public API which is an options property passed to the
constructor.

Refs: nodejs#445

PR-URL: nodejs#25201
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
Trott authored and refack committed Jan 10, 2019
1 parent 27a3c3d commit 95a56b5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ function Socket(options) {
options.allowHalfOpen = true;
// For backwards compat do not emit close on destroy.
options.emitClose = false;
// Handle strings directly.
options.decodeStrings = false;
stream.Duplex.call(this, options);

// Default to *not* allowing half open sockets.
Expand Down Expand Up @@ -308,9 +310,6 @@ function Socket(options) {
this._pendingData = null;
this._pendingEncoding = '';

// handle strings directly
this._writableState.decodeStrings = false;

// If we have a handle, then start the flow of data into the
// buffer. if not, then this will happen when we connect
if (this._handle && options.readable !== false) {
Expand Down

0 comments on commit 95a56b5

Please sign in to comment.