diff --git a/package.json b/package.json index b4bbeb1..ca1ac7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "urllib-sync", - "version": "1.1.4", + "version": "1.1.5", "description": "sync http request", "main": "index.js", "scripts": { @@ -22,7 +22,7 @@ }, "license": "MIT", "dependencies": { - "urllib": "~2.11.0", + "urllib": "~2.34.1", "utility": "~1.7.1" }, "devDependencies": { diff --git a/test/index.test.js b/test/index.test.js index 0fc1693..fbcfef3 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -16,13 +16,6 @@ var fs = require('fs'); describe('urllib-sync', function () { describe('request()', function () { - it('should request gbk ok', function () { - this.timeout(4000); - var res = urllib.request('http://www.taobao.com/go/rgn/tmall/header/2014/sub-nav.php'); - var data = iconv.decode(res.data, 'gbk'); - data.should.containEql('天猫'); - res.status.should.equal(200); - }); it('should request text ok', function () { this.timeout(30000); @@ -58,12 +51,12 @@ describe('urllib-sync', function () { it('should writeFile ok', function () { this.timeout(4000); - var res = urllib.request('http://www.taobao.com/go/rgn/tmall/header/2014/sub-nav.php', { + var res = urllib.request('https://npm.taobao.org/', { writeFile: './tmp' }); res.status.should.equal(200); - var data = iconv.decode(fs.readFileSync('./tmp'), 'gbk'); - data.should.containEql('天猫'); + var data = iconv.decode(fs.readFileSync('./tmp'), 'utf-8'); + data.should.containEql('淘宝 NPM 镜像'); fs.unlinkSync('./tmp'); }); @@ -72,8 +65,8 @@ describe('urllib-sync', function () { var res = urllib.request('http://www.taobao.com/not/exist/file/path', { writeFile: './404file' }); - res.status.should.equal(302); - res.data.toString().should.match(/302/); + res.status.should.equal(301); + res.data.toString().should.match(/301/); fs.existsSync('./404file').should.equal(false); }); });