Comparing version 0.2.12 to 0.2.13
var req = require('../'); | ||
var rs = req('http://httpbin.org/deflate'); | ||
var rs = req('http://httpbin.org/stream/10'); | ||
rs.on('error', function(err){ | ||
@@ -10,3 +10,3 @@ console.log('[ERROR]', err.message); | ||
offset += chunk.length; | ||
buffers.push(chunk.toString('utf8')); | ||
buffers.push(chunk); | ||
}); | ||
@@ -13,0 +13,0 @@ rs.on('end', function(){ |
@@ -19,3 +19,3 @@ // Copyright 2014 Tjatse | ||
var Stream = require('stream').Stream, | ||
URI = require('URIjs'), | ||
URI = require('urijs'), | ||
util = require('util'), | ||
@@ -122,3 +122,3 @@ http = require('http'), | ||
} | ||
aborted && onError.call(this, new Error('ETIMEOUT')); | ||
aborted && onError.call(this, o, new Error('ETIMEOUT')); | ||
return; | ||
@@ -125,0 +125,0 @@ } |
@@ -127,10 +127,6 @@ // Copyright 2014 Tjatse | ||
var html = resp.body.toString('ascii'), meta; | ||
if(meta = html.match(/<meta\s*charset=["']*([a-zA-Z\d\-]*)["']*\s*\/{0,1}?>/i)){ | ||
if((meta = html.match(/<meta(?!\s*(?:name|value)\s*=)[^>]*?charset\s*=[\s"']*([^\s"'/>]*)/i)) && meta.length > 1){ | ||
charset = meta[1]; | ||
} | ||
if(!charset && (meta = html.match(/<meta[\s\S]*http-equiv=["']*content-type["']*[\s\S]*\/{0,1}?>/i))){ | ||
if(meta = meta[0].match(/charset\s*=\s*([a-zA-Z\d\-]*)["';]/i)){ | ||
charset = meta[1]; | ||
} | ||
} | ||
} | ||
@@ -137,0 +133,0 @@ return { |
var qs = require('querystring'), | ||
URI = require('URIjs'), | ||
URI = require('urijs'), | ||
http = require('http'), | ||
@@ -4,0 +4,0 @@ https = require('https'), |
{ | ||
"name": "req-fast", | ||
"version": "0.2.12", | ||
"version": "0.2.13", | ||
"description": "This module is designed to be the fast, lightweight way to fetch the web content(HTML stream).", | ||
@@ -31,5 +31,5 @@ "main": "lib/req.js", | ||
"tunnel":"^0.0.3", | ||
"URIjs": "^1.14.0", | ||
"urijs": "~1.17.0", | ||
"random-ua": "^0.0.6", | ||
"iconv-lite": "^0.4.4" | ||
"iconv-lite": "^0.4.13" | ||
}, | ||
@@ -36,0 +36,0 @@ "devDependencies": { |
@@ -17,6 +17,5 @@ var req = require('../'), | ||
}); | ||
it.skip('avoid messy codes', function(done){ | ||
it('avoid messy codes when multi charset detected', function(done){ | ||
req({ | ||
url: 'http://game.163.com/14/0506/10/9RI8M9AO00314SDA.html', | ||
charset: 'gbk' | ||
url: 'http://www.ce.cn/xwzx/gnsz/gdxw/201505/25/t20150525_5453608.shtml' | ||
}, function(err, resp){ | ||
@@ -27,7 +26,7 @@ should.not.exist(err); | ||
expect(resp.body).to.match(/^\s*</); | ||
expect(resp.body).to.have.string('亲爱的冒险者'); | ||
expect(resp.body).to.have.string('饮用水新国标实施'); | ||
done(); | ||
}); | ||
}) | ||
}); | ||
}) | ||
}); |
57339
1186
+ Addedurijs@~1.17.0
+ Addedurijs@1.17.1(transitive)
- RemovedURIjs@^1.14.0
- RemovedURIjs@1.16.1(transitive)
Updatediconv-lite@^0.4.13