use always random subdomain for getResponse

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen committed 2021-02-09 07:50:16 +02:00
1 parent 827571b948
commit a9227bd02e
2 files changed
+8 -6

No files matched your search

+7 -4
View File
@@ -3,7 +3,7 @@
import { stringify } from "querystring";
import { EventEmitter } from "../../common/event-emitter";
import { cancelableFetch } from "../utils/cancelableFetch";
import { randomBytes } from "crypto";
export interface JsonApiData {
}
@@ -55,7 +55,10 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
return this.request<T>(path, params, { ...reqInit, method: "get" });
}
getResponse(reqUrl: string, params?: P, init: RequestInit = { }): Promise<Response> {
getResponse(path: string, params?: P, init: RequestInit = {}): Promise<Response> {
const reqPath = `${this.config.apiBase}${path}`;
const subdomain = randomBytes(2).toString("hex");
let reqUrl = `http://${subdomain}.${window.location.host}${reqPath}`; // hack around browser connection limits (chromium allows 6 per domain)
const reqInit: RequestInit = { ...init };
const { query } = params || {} as P;
@@ -70,8 +73,8 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
}
const infoLog: JsonApiLog = {
method: `${reqInit.method.toUpperCase()} (stream)`,
reqUrl,
method: reqInit.method.toUpperCase(),
reqUrl: reqPath,
reqInit,
};
+1 -2
View File
@@ -372,8 +372,7 @@ export class KubeApi<T extends KubeObject = any> {
}
const { abortController, namespace, callback } = opts;
// FIXME
const watchUrl = `http://${this.kind}-watch.${window.location.host}${apiKubePrefix}${this.getWatchUrl(namespace)}`;
const watchUrl = this.getWatchUrl(namespace);
const responsePromise = this.request.getResponse(watchUrl, null, {
signal: abortController.signal
});