summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/_http_outgoing.js10
-rw-r--r--lib/_tls_wrap.js2
-rw-r--r--lib/buffer.js9
-rw-r--r--lib/internal/streams/lazy_transform.js2
-rw-r--r--lib/net.js3
-rw-r--r--lib/string_decoder.js3
6 files changed, 18 insertions, 11 deletions
diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js
index e1e78e010c..18a610feab 100644
--- a/lib/_http_outgoing.js
+++ b/lib/_http_outgoing.js
@@ -130,7 +130,7 @@ OutgoingMessage.prototype._send = function(data, encoding, callback) {
data = this._header + data;
} else {
this.output.unshift(this._header);
- this.outputEncodings.unshift('binary');
+ this.outputEncodings.unshift('latin1');
this.outputCallbacks.unshift(null);
this.outputSize += this._header.length;
if (typeof this._onPendingData === 'function')
@@ -453,7 +453,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding, callback) {
if (typeof chunk === 'string' &&
encoding !== 'hex' &&
encoding !== 'base64' &&
- encoding !== 'binary') {
+ encoding !== 'latin1') {
len = Buffer.byteLength(chunk, encoding);
chunk = len.toString(16) + CRLF + chunk + CRLF;
ret = this._send(chunk, encoding, callback);
@@ -468,7 +468,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding, callback) {
this.connection.cork();
process.nextTick(connectionCorkNT, this.connection);
}
- this._send(len.toString(16), 'binary', null);
+ this._send(len.toString(16), 'latin1', null);
this._send(crlf_buf, null, null);
this._send(chunk, encoding, null);
ret = this._send(crlf_buf, null, callback);
@@ -582,10 +582,10 @@ OutgoingMessage.prototype.end = function(data, encoding, callback) {
}
if (this._hasBody && this.chunkedEncoding) {
- ret = this._send('0\r\n' + this._trailer + '\r\n', 'binary', finish);
+ ret = this._send('0\r\n' + this._trailer + '\r\n', 'latin1', finish);
} else {
// Force a flush, HACK.
- ret = this._send('', 'binary', finish);
+ ret = this._send('', 'latin1', finish);
}
if (this.connection && data)
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js
index b766953240..c2ecd07a4b 100644
--- a/lib/_tls_wrap.js
+++ b/lib/_tls_wrap.js
@@ -608,7 +608,7 @@ TLSSocket.prototype.setServername = function(name) {
TLSSocket.prototype.setSession = function(session) {
if (typeof session === 'string')
- session = Buffer.from(session, 'binary');
+ session = Buffer.from(session, 'latin1');
this._handle.setSession(session);
};
diff --git a/lib/buffer.js b/lib/buffer.js
index d3cbdf66a3..ab012c96b5 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -331,6 +331,7 @@ Buffer.isEncoding = function(encoding) {
case 'utf8':
case 'utf-8':
case 'ascii':
+ case 'latin1':
case 'binary':
case 'base64':
case 'ucs2':
@@ -408,6 +409,7 @@ function byteLength(string, encoding) {
for (;;) {
switch (encoding) {
case 'ascii':
+ case 'latin1':
case 'binary':
return len;
@@ -509,8 +511,9 @@ function slowToString(encoding, start, end) {
case 'ascii':
return this.asciiSlice(start, end);
+ case 'latin1':
case 'binary':
- return this.binarySlice(start, end);
+ return this.latin1Slice(start, end);
case 'base64':
return this.base64Slice(start, end);
@@ -658,6 +661,7 @@ function slowIndexOf(buffer, val, byteOffset, encoding, dir) {
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
+ case 'latin1':
case 'binary':
return binding.indexOfString(buffer, val, byteOffset, encoding, dir);
@@ -801,8 +805,9 @@ Buffer.prototype.write = function(string, offset, length, encoding) {
case 'ascii':
return this.asciiWrite(string, offset, length);
+ case 'latin1':
case 'binary':
- return this.binaryWrite(string, offset, length);
+ return this.latin1Write(string, offset, length);
case 'base64':
// Warning: maxLength not taken into account in base64Write
diff --git a/lib/internal/streams/lazy_transform.js b/lib/internal/streams/lazy_transform.js
index 7e290b16cf..bd68bef4b6 100644
--- a/lib/internal/streams/lazy_transform.js
+++ b/lib/internal/streams/lazy_transform.js
@@ -22,7 +22,7 @@ util.inherits(LazyTransform, stream.Transform);
get: function() {
stream.Transform.call(this, this._options);
this._writableState.decodeStrings = false;
- this._writableState.defaultEncoding = 'binary';
+ this._writableState.defaultEncoding = 'latin1';
return this[prop];
},
set: function(val) {
diff --git a/lib/net.js b/lib/net.js
index 509112f58f..d64a264f96 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -726,8 +726,9 @@ Socket.prototype._write = function(data, encoding, cb) {
function createWriteReq(req, handle, data, encoding) {
switch (encoding) {
+ case 'latin1':
case 'binary':
- return handle.writeBinaryString(req, data);
+ return handle.writeLatin1String(req, data);
case 'buffer':
return handle.writeBuffer(req, data);
diff --git a/lib/string_decoder.js b/lib/string_decoder.js
index aaadfd8934..6eb71efc07 100644
--- a/lib/string_decoder.js
+++ b/lib/string_decoder.js
@@ -19,6 +19,7 @@ function normalizeEncoding(enc) {
return 'utf16le';
case 'base64':
case 'ascii':
+ case 'latin1':
case 'binary':
case 'hex':
return enc;
@@ -225,7 +226,7 @@ function base64End(buf) {
return r;
}
-// Pass bytes on through for single-byte encodings (e.g. ascii, binary, hex)
+// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
function simpleWrite(buf) {
return buf.toString(this.encoding);
}