Skip to content

Commit

Permalink
remove hook and add event 'before-send'
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Jul 30, 2018
1 parent d74dc7b commit c560069
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 54 deletions.
3 changes: 2 additions & 1 deletion dist/cos-js-sdk-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.4.10';
COS.version = '0.4.11';

module.exports = COS;

Expand Down Expand Up @@ -5751,6 +5751,7 @@ function _submitRequest(params, callback) {
};
}

cos.emit('before-send', opt);
var sender = REQUEST(opt, function (err, response, body) {

// 返回内容添加 状态码 和 headers
Expand Down
2 changes: 1 addition & 1 deletion dist/cos-js-sdk-v5.min.js

Large diffs are not rendered by default.

21 changes: 2 additions & 19 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -1905,24 +1905,6 @@ function submitRequest(params, callback) {
});
}


// 请求前后增加钩子处理
_request = function (opt, callback) {
var self = this;
self._runRegister('before-send', opt, function () {
REQUEST(opt, function (err, response, body) {
var data = {
error: err,
response: response,
body: body,
};
self._runRegister('after-send', data, function () {
callback(err, response, body);
});
});
});
};

// 发起请求
function _submitRequest(params, callback) {
var self = this;
Expand Down Expand Up @@ -1980,7 +1962,8 @@ function _submitRequest(params, callback) {
};
}

var sender = _request.call(self, opt, function (err, response, body) {
cos.emit('before-send', opt);
var sender = REQUEST(opt, function (err, response, body) {

// 返回内容添加 状态码 和 headers
var hasReturned;
Expand Down
4 changes: 1 addition & 3 deletions src/cos.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var util = require('./util');
var event = require('./event');
var task = require('./task');
var hook = require('./hook');
var base = require('./base');
var advance = require('./advance');

Expand Down Expand Up @@ -39,13 +38,12 @@ var COS = function (options) {
}
event.init(this);
task.init(this);
hook.init(this);
};

util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.4.10';
COS.version = '0.4.11';

module.exports = COS;
30 changes: 0 additions & 30 deletions src/hook.js

This file was deleted.

0 comments on commit c560069

Please sign in to comment.