Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
avenwu.wwb committed Mar 11, 2016
1 parent 16c1726 commit bce1449
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,15 @@ bugfix:修改了路径匹配可能多加一个 `/` 的问题
1. 修复自定义插件不能获取[values]()的值,即 `pattern plugin://{key}` 无法正确获取ruleValue的问题
2. 限制自定义插件的名称不能与内置的协议名称冲突,如果冲突则该自定义插件将无效

# v0.9.0
### v0.9.0
1. **重要bugfix:**Fix https post数据时可能出现pending的问题
2. 新增[etag](https://github.com/avwo/whistle/wiki/%E5%8A%9F%E8%83%BD%E5%88%97%E8%A1%A8#etag)协议,用于修改请求头的etag
3. 支持通过`ua://``referer://``reqType://``resType://`等,把对应的字段置空

# v0.9.1
1. 新增[reqCharset](https://github.com/avwo/whistle/wiki/%E5%8A%9F%E8%83%BD%E5%88%97%E8%A1%A8#reqcharset)[resCharset](https://github.com/avwo/whistle/wiki/%E5%8A%9F%E8%83%BD%E5%88%97%E8%A1%A8#rescharset)两个协议,分别用于快速修改请求、响应的编码
2. bugfix:修复可能出现请求出错的情况,https://github.com/nodejs/node/pull/4482

### -
具体参考:[功能列表](https://github.com/avwo/whistle/wiki/%E5%8A%9F%E8%83%BD%E5%88%97%E8%A1%A8#%E7%9B%AE%E5%BD%95)

Expand Down
15 changes: 12 additions & 3 deletions lib/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var path = require('path');
var os = require('os');
var httpAgent = require('http').Agent;
var httpsAgent = require('https').Agent;
var fse = require('fs-extra');
var pkgConf = require('../package.json');
var config = require('util')._extend(exports, pkgConf);
Expand Down Expand Up @@ -28,13 +30,20 @@ function getDataDir(dirname) {
exports.getDataDir = getDataDir;

function createAgent(config, https) {
return new (require(https ? 'https' : 'http').Agent)(config)
return new (https ? httpsAgent : httpAgent)(config)
.on('free', preventThrowOutError);
}

function preventThrowOutError(socket) {
socket.removeListener('error', noop);
socket.on('error', noop);
socket.removeListener('error', freeSocketErrorListener);
socket.on('error', freeSocketErrorListener);
}

function freeSocketErrorListener(err) {
var socket = this;
socket.destroy();
socket.emit('agentRemove');
socket.removeListener('error', freeSocketErrorListener);
}

function noop() {}
Expand Down

0 comments on commit bce1449

Please sign in to comment.