Skip to content

Commit

Permalink
fix: #3983 (#4058)
Browse files Browse the repository at this point in the history
(cherry picked from commit 6ce4e05)
  • Loading branch information
czy88840616 committed Sep 22, 2024
1 parent f2fef8a commit 97e8d71
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core/src/util/httpclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ export class HttpClient {
url: string,
options?: HttpClientOptions
): Promise<HttpClientResponse> {
return makeHttpRequest(url, Object.assign(this.defaultOptions, options));
return makeHttpRequest(
url,
Object.assign({}, this.defaultOptions, options)
);
}
}
16 changes: 16 additions & 0 deletions packages/core/test/util/httpclient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,20 @@ describe('/test/util/httpclient.test.ts', function () {
expect(result.data['headers']['x-power-by']).toEqual('midway');
manager.close();
});

it("should not override default options", async () => {
const manager = await createHttpServer();
const httpclient = new HttpClient({
headers: {
'x-power-by': 'midway',
},
});

await httpclient.request(`http://127.1:${manager.getPort()}/`, {
dataType: 'json'
});

expect(httpclient.defaultOptions['dataType']).toBeUndefined();
manager.close();
});
});

0 comments on commit 97e8d71

Please sign in to comment.