File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
templates/base/http-clients Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -99,14 +99,24 @@ export class HttpClient<SecurityDataType = unknown> {
9999 }
100100 }
101101
102+ let headers: Headers | Record<string , string | undefined > | undefined;
103+ if (options.headers instanceof Headers) {
104+ headers = new Headers(options.headers);
105+ if (type && type !== ContentType.FormData) {
106+ headers.set('Content-Type', type);
107+ }
108+ } else {
109+ headers = { ...options.headers } as Record<string , string | undefined >;
110+ if (type && type !== ContentType.FormData) {
111+ headers['Content-Type'] = type;
112+ }
113+ }
114+
102115 const request = this.ky(path, {
103- ...options,
104- headers: {
105- ...(options.headers || {}),
106- ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}),
107- },
108- searchParams: query,
109- body: body as any,
116+ ...options,
117+ headers,
118+ searchParams: query,
119+ body: body as any,
110120 });
111121
112122<% if (config .unwrapResponseData ) { % >
You can’t perform that action at this time.
0 commit comments