Commit 7caef68e authored by Medicean's avatar Medicean

(Fix:Modules) 修复数据截取Bug

parent 9e422807
...@@ -409,7 +409,6 @@ class Request { ...@@ -409,7 +409,6 @@ class Request {
let foundTagS = false; let foundTagS = false;
let foundTagE = false; let foundTagE = false;
res.on('data', (chunk) => { res.on('data', (chunk) => {
// 这样吧,我们尝试一种新的数据截取算法: // 这样吧,我们尝试一种新的数据截取算法:
// 1. 把数据流转换为16进制 // 1. 把数据流转换为16进制
let chunkHex = Buffer let chunkHex = Buffer
...@@ -421,7 +420,7 @@ class Request { ...@@ -421,7 +420,7 @@ class Request {
if (chunkHex.indexOf(tagHexS) >= 0 && chunkHex.lastIndexOf(tagHexE) >= 0) { if (chunkHex.indexOf(tagHexS) >= 0 && chunkHex.lastIndexOf(tagHexE) >= 0) {
let index_s = chunkHex.indexOf(tagHexS); let index_s = chunkHex.indexOf(tagHexS);
let index_e = chunkHex.lastIndexOf(tagHexE); let index_e = chunkHex.lastIndexOf(tagHexE);
temp = chunkHex.substr(index_s + tagHexS.length, index_e - index_s - tagHexE.length); temp = chunkHex.substr(index_s + tagHexS.length, index_e - index_s - tagHexS.length);
foundTagS = foundTagE = // 如果只包含前截断,则截取后边 foundTagS = foundTagE = // 如果只包含前截断,则截取后边
true; true;
} else if (chunkHex.indexOf(tagHexS) >= 0 && chunkHex.lastIndexOf(tagHexE) === -1) { } else if (chunkHex.indexOf(tagHexS) >= 0 && chunkHex.lastIndexOf(tagHexE) === -1) {
...@@ -478,8 +477,7 @@ function detectEncoding(buffer, options) { ...@@ -478,8 +477,7 @@ function detectEncoding(buffer, options) {
// var VALID_ENCODINGS = ['gb2312', 'gbk', 'utf-8', 'big5', 'euc-kr','euc-jp']; // var VALID_ENCODINGS = ['gb2312', 'gbk', 'utf-8', 'big5', 'euc-kr','euc-jp'];
if (encoding === null || !iconv.encodingExists(encoding) || confidence < minConfidence) { if (encoding === null || !iconv.encodingExists(encoding) || confidence < minConfidence) {
return verbose ? return verbose ? {
{
encoding: defaultEncoding, encoding: defaultEncoding,
oriEncoding: encoding, oriEncoding: encoding,
confidence: confidence confidence: confidence
...@@ -487,8 +485,7 @@ function detectEncoding(buffer, options) { ...@@ -487,8 +485,7 @@ function detectEncoding(buffer, options) {
defaultEncoding; defaultEncoding;
} else { } else {
encoding = encoding.toUpperCase(); encoding = encoding.toUpperCase();
return verbose ? return verbose ? {
{
encoding: encoding, encoding: encoding,
oriEncoding: encoding, oriEncoding: encoding,
confidence: confidence confidence: confidence
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment