Skip to content

Commit

Permalink
Added Content-Type header to all HTTP requests
Browse files Browse the repository at this point in the history
  • Loading branch information
andfoy committed May 6, 2017
1 parent 576fdbb commit b22aefe
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions spyder_terminal/server/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ var term,
charHeight,
path;

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");

var terminalContainer = document.getElementById('terminal-container');

function setTerminalSize () {
Expand Down Expand Up @@ -48,7 +51,7 @@ function createTerminal() {
rows = size.rows,
url = '/api/terminals/' + pid + '/size?cols=' + cols + '&rows=' + rows;

fetch(url, {method: 'POST'});
fetch(url, {method: 'POST', headers: myHeaders});
});
protocol = (location.protocol === 'https:') ? 'wss://' : 'ws://';
socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + '/terminals/';
Expand All @@ -64,7 +67,7 @@ function createTerminal() {
console.log(rows);


fetch('/api/terminals?cols=' + cols + '&rows=' + rows, {method: 'POST'}).then(function (res) {
fetch('/api/terminals?cols=' + cols + '&rows=' + rows, {method: 'POST', headers: myHeaders}).then(function (res) {

charWidth = Math.ceil(term.element.offsetWidth / cols);
charHeight = Math.ceil(term.element.offsetHeight / rows);
Expand Down Expand Up @@ -113,9 +116,14 @@ function clearTerm()
term.send('clear\n');
}

function exec(cmd)
{
term.send(''+cmd+'\n');
}

function closeTerm() {
console.log("Closed via server");
term.writeln("Pipe closed")
term.writeln("Pipe closed");
}

function runRealTerminal() {
Expand Down

0 comments on commit b22aefe

Please sign in to comment.