Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复axios 配置污染 #26

Open
wants to merge 2 commits 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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
/.settings/
/doc/
/node_modules/
/src/node_modules/
/src/node_modules/

.idea
.DS_Store
.vscode
12 changes: 7 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import xml2js from './xml2js';
import obsModel from './obsModel';
import v2Model from './v2Model';

const http = axios.create()

const crypto = {
createHmac : function(algorithm, key){
let algorithmKey;
Expand Down Expand Up @@ -1081,7 +1083,7 @@ Utils.prototype.makeParam = function(methodName, param){
this.log.runLog('error', methodName, opt.err);
return opt;
}
const newKey = _key.slice(0, 1).toLowerCase() + _key.slice(1);
const newKey = _key.slice(0, 1).toLowerCase() + _key.slice(1);
_value[newKey] = _keyValue;
}
}
Expand Down Expand Up @@ -1638,7 +1640,7 @@ Utils.prototype.makeRequest = function(methodName, opt, retryCount, bc){
baseUrl = httpPrefix + host + portInfo;
}

let reopt = {
const requestConfig = {
method : method,
// fix bug, axios will abandon the base url if the request url starts with '//', so use the completed url to avoid it
url : baseUrl + path,
Expand Down Expand Up @@ -1676,9 +1678,9 @@ Utils.prototype.makeRequest = function(methodName, opt, retryCount, bc){
return bc(e);
}

reopt.data = srcFile;
requestConfig.data = srcFile;
}
axios.request(reopt).then(function (response) {
http.request(requestConfig).then(function (response) {
log.runLog('info', methodName, 'http cost ' + (new Date().getTime()-start) + ' ms');
that.getRequest(methodName, response, signatureContext, retryCount, opt.$requestParam, bc);
}).catch(function (err) {
Expand Down Expand Up @@ -2087,7 +2089,7 @@ Utils.prototype.createV2SignedUrlSync = function(param){
}
}
queryParamsKeys.sort();
let isShareFolder = policy && prefix;
let isShareFolder = policy && prefix;
let flag = false;
let _resource = [];
let safeKey = policy && prefix ? '': '/';
Expand Down