Skip to content

Commit

Permalink
fix: remove node enviroment x-oss-user-agent (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
taotao7 authored Sep 27, 2021
1 parent 6f3b456 commit fe39041
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ async function request(params) {
result.data = await this.parseXML(result.data);
}
return result;
};
}

proto._getResource = function _getResource(params) {
let resource = '/';
Expand Down
4 changes: 3 additions & 1 deletion lib/common/utils/createRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ function createRequest(params) {
}
const headers = {
'x-oss-date': dateFormat(date, 'UTC:ddd, dd mmm yyyy HH:MM:ss \'GMT\''),
'x-oss-user-agent': this.userAgent
};
if (typeof window !== 'undefined') {
headers['x-oss-user-agent']= this.userAgent
}
if (this.userAgent.includes('nodejs')) {
headers['User-Agent'] = this.userAgent;
}
Expand Down
7 changes: 5 additions & 2 deletions lib/common/utils/createRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { getReqUrl } = require('../client/getReqUrl');
interface Headers {
[propName: string]: any
'x-oss-date': string,
'x-oss-user-agent': string,
'x-oss-user-agent'?: string,
}

interface ReqParams {
Expand All @@ -35,9 +35,12 @@ export function createRequest(this: any, params) {
}
const headers: Headers = {
'x-oss-date': dateFormat(date, 'UTC:ddd, dd mmm yyyy HH:MM:ss \'GMT\''),
'x-oss-user-agent': this.userAgent
};

if (typeof window !== 'undefined') {
headers['x-oss-user-agent'] = this.userAgent;
}

if (this.userAgent.includes('nodejs')) {
headers['User-Agent'] = this.userAgent;
}
Expand Down

0 comments on commit fe39041

Please sign in to comment.