Skip to content

Commit 3bf1be7

Browse files
duan007abinghaiwang
authored andcommitted
fix: signatureUrl With response settings (#465)
1 parent dd3c84f commit 3bf1be7

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/common/signUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ exports._signatureForURL = function _signatureForURL(accessKeySecret, options, r
115115
if (options.response) {
116116
Object.keys(options.response).forEach((k) => {
117117
const key = `response-${k.toLowerCase()}`;
118-
subResource[key] = options.response[key];
118+
subResource[key] = options.response[k];
119119
});
120120
}
121121

test/browser/browser.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,16 @@ describe('browser', () => {
579579
assert.equal(urlRes.data.toString(), result.content.toString());
580580
});
581581

582+
it('should signature url with reponse limitation', function* () {
583+
const response = {
584+
'content-type': 'xml',
585+
'content-language': 'zh-cn',
586+
};
587+
const url = this.store.signatureUrl(this.name, { response });
588+
assert(url.indexOf('response-content-type=xml') !== -1);
589+
assert(url.indexOf('response-content-language=zh-cn') !== -1);
590+
});
591+
582592
it('should signature url with custom host ok', function () {
583593
const store = oss(Object.assign({}, ossConfig, {
584594
endpoint: 'www.aliyun.com',

test/node/object.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,16 @@ describe('test/object.test.js', () => {
800800
assert.equal(urlRes.data.toString(), result.content.toString());
801801
});
802802

803+
it('should signature url with reponse limitation', function* () {
804+
const response = {
805+
'content-type': 'xml',
806+
'content-language': 'zh-cn',
807+
};
808+
const url = this.store.signatureUrl(this.name, { response });
809+
assert(url.indexOf('response-content-type=xml') !== -1);
810+
assert(url.indexOf('response-content-language=zh-cn') !== -1);
811+
});
812+
803813
it('should signature url with image processed and get object ok', function* () {
804814
const name = `${prefix}ali-sdk/oss/nodejs-test-signature-1024x768.png`;
805815
const originImagePath = path.join(__dirname, 'nodejs-1024x768.png');

0 commit comments

Comments
 (0)