Skip to content

Commit bd3a0d8

Browse files
committed
Simplify test and fix header order precedence
1 parent 2292d9b commit bd3a0d8

File tree

2 files changed

+196
-143
lines changed

2 files changed

+196
-143
lines changed

src/api/coderApi.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export class CoderApi extends Api {
107107
watchBuildLogsByBuildId = async (
108108
buildId: string,
109109
logs: ProvisionerJobLog[],
110+
options?: ClientOptions,
110111
) => {
111112
const searchParams = new URLSearchParams({ follow: "true" });
112113
if (logs.length) {
@@ -116,6 +117,7 @@ export class CoderApi extends Api {
116117
return this.createWebSocket<ProvisionerJobLog>({
117118
apiRoute: `/api/v2/workspacebuilds/${buildId}/logs`,
118119
searchParams,
120+
options,
119121
});
120122
};
121123

@@ -132,7 +134,7 @@ export class CoderApi extends Api {
132134
coderSessionTokenHeader
133135
] as string | undefined;
134136

135-
const headers = await getHeaders(
137+
const headersFromCommand = await getHeaders(
136138
baseUrlRaw,
137139
getHeaderCommand(vscode.workspace.getConfiguration()),
138140
this.output,
@@ -142,18 +144,20 @@ export class CoderApi extends Api {
142144
vscode.workspace.getConfiguration(),
143145
);
144146

147+
const headers = {
148+
...(token ? { [coderSessionTokenHeader]: token } : {}),
149+
...configs.options?.headers,
150+
...headersFromCommand,
151+
};
152+
145153
const webSocket = new OneWayWebSocket<TData>({
146154
location: baseUrl,
147155
...configs,
148156
options: {
157+
...configs.options,
149158
agent: httpAgent,
150159
followRedirects: true,
151-
headers: {
152-
...(token ? { [coderSessionTokenHeader]: token } : {}),
153-
...configs.options?.headers,
154-
...headers,
155-
},
156-
...configs.options,
160+
headers,
157161
},
158162
});
159163

0 commit comments

Comments
 (0)