Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Added Content-Type header to all HTTP requests #50

Merged
merged 1 commit into from
May 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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