Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

feat: update urllib version #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "urllib-sync",
"version": "1.1.4",
"version": "1.1.5",
"description": "sync http request",
"main": "index.js",
"scripts": {
Expand All @@ -22,7 +22,7 @@
},
"license": "MIT",
"dependencies": {
"urllib": "~2.11.0",
"urllib": "~2.34.1",
"utility": "~1.7.1"
},
"devDependencies": {
Expand Down
17 changes: 5 additions & 12 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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');
});

Expand All @@ -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);
});
});
Expand Down