From c08a1872ccadb3395f05513a605a6d5c85503e50 Mon Sep 17 00:00:00 2001 From: Tanuj Mittal Date: Tue, 6 Oct 2020 16:55:13 -0700 Subject: [PATCH] Add correct content-type header to terminals calls (#258) --- src/Terminal/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Terminal/index.ts b/src/Terminal/index.ts index 61ec8c04a..79c8a8809 100644 --- a/src/Terminal/index.ts +++ b/src/Terminal/index.ts @@ -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 = { 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 }; }