add custom header support and fix ui

This commit is contained in:
Sourabh Jain 2025-04-09 16:44:28 +05:30
parent 2a44c619c5
commit b26420cd85
3 changed files with 15 additions and 9 deletions

View File

@ -8,14 +8,14 @@ import { configContext } from "../../../../ConfigContext";
import { userContext } from '../../../../UserContext';
import { armRequest } from "../../../../Utils/arm/request";
import {
Authorization,
ConnectTerminalResponse,
NetworkType,
OsType,
ProvisionConsoleResponse,
SessionType,
Settings,
ShellType
Authorization,
ConnectTerminalResponse,
NetworkType,
OsType,
ProvisionConsoleResponse,
SessionType,
Settings,
ShellType
} from "../Models/DataModels";
import { getLocale } from '../Utils/CommonUtils';

View File

@ -29,6 +29,7 @@ export class AttachAddon implements ITerminalAddon {
this._endMarker = options?.endMarker;
this._terminalSuppressedData = options?.terminalSuppressedData;
this._socketData = '';
this._flag = true;
}
public activate(terminal: Terminal): void {

View File

@ -47,6 +47,7 @@ interface Options {
body?: unknown;
queryParams?: ARMQueryParams;
contentType?: string;
customHeaders?: Record<string, string>;
}
export async function armRequestWithoutPolling<T>({
@ -57,6 +58,7 @@ export async function armRequestWithoutPolling<T>({
body: requestBody,
queryParams,
contentType,
customHeaders
}: Options): Promise<{ result: T; operationStatusUrl: string }> {
const url = new URL(path, host);
url.searchParams.append("api-version", configContext.armAPIVersion || apiVersion);
@ -65,7 +67,7 @@ export async function armRequestWithoutPolling<T>({
queryParams.metricNames && url.searchParams.append("metricnames", queryParams.metricNames);
}
if (!userContext.authorizationToken) {
if (!userContext.authorizationToken && !customHeaders["Authorization"]) {
throw new Error("No authority token provided");
}
@ -74,6 +76,7 @@ export async function armRequestWithoutPolling<T>({
headers: {
Authorization: userContext.authorizationToken,
[HttpHeaders.contentType]: contentType || "application/json",
...customHeaders
},
body: requestBody ? JSON.stringify(requestBody) : undefined,
});
@ -109,6 +112,7 @@ export async function armRequest<T>({
body: requestBody,
queryParams,
contentType,
customHeaders
}: Options): Promise<T> {
const armRequestResult = await armRequestWithoutPolling<T>({
host,
@ -118,6 +122,7 @@ export async function armRequest<T>({
body: requestBody,
queryParams,
contentType,
customHeaders
});
const operationStatusUrl = armRequestResult.operationStatusUrl;
if (operationStatusUrl) {