Add correct content-type header to terminals calls (#258)

This commit is contained in:
Tanuj Mittal 2020-10-06 16:55:13 -07:00 committed by GitHub
parent 0cc38868a6
commit c08a1872cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -7,7 +7,7 @@ import { JupyterLabAppFactory } from "./JupyterLabAppFactory";
import { Action } from "../Shared/Telemetry/TelemetryConstants";
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
import { updateUserContext } from "../UserContext";
import { TerminalQueryParams } from "../Common/Constants";
import { HttpHeaders, TerminalQueryParams } from "../Common/Constants";
const getUrlVars = (): { [key: string]: string } => {
const vars: { [key: string]: string } = {};
@ -20,16 +20,20 @@ const getUrlVars = (): { [key: string]: string } => {
const createServerSettings = (urlVars: { [key: string]: string }): ServerConnection.ISettings => {
let body: BodyInit;
let headers: HeadersInit;
if (urlVars.hasOwnProperty(TerminalQueryParams.TerminalEndpoint)) {
body = JSON.stringify({
endpoint: urlVars[TerminalQueryParams.TerminalEndpoint]
});
headers = {
[HttpHeaders.contentType]: "application/json"
};
}
const server = urlVars[TerminalQueryParams.Server];
let options: Partial<ServerConnection.ISettings> = {
baseUrl: server,
init: { body },
init: { body, headers },
fetch: window.parent.fetch
};
if (urlVars.hasOwnProperty(TerminalQueryParams.Token)) {
@ -37,7 +41,7 @@ const createServerSettings = (urlVars: { [key: string]: string }): ServerConnect
baseUrl: server,
token: urlVars[TerminalQueryParams.Token],
appendToken: true,
init: { body },
init: { body, headers },
fetch: window.parent.fetch
};
}