##// END OF EJS Templates
fix url encoding in services...
MinRK -
Show More
@@ -25,12 +25,12 b' var IPython = (function (IPython) {'
25 * A Kernel Class to communicate with the Python kernel
25 * A Kernel Class to communicate with the Python kernel
26 * @Class Kernel
26 * @Class Kernel
27 */
27 */
28 var Kernel = function (base_url) {
28 var Kernel = function (kernel_service_url) {
29 this.kernel_id = null;
29 this.kernel_id = null;
30 this.shell_channel = null;
30 this.shell_channel = null;
31 this.iopub_channel = null;
31 this.iopub_channel = null;
32 this.stdin_channel = null;
32 this.stdin_channel = null;
33 this.base_url = base_url;
33 this.kernel_service_url = kernel_service_url;
34 this.running = false;
34 this.running = false;
35 this.username = "username";
35 this.username = "username";
36 this.session_id = utils.uuid();
36 this.session_id = utils.uuid();
@@ -94,8 +94,7 b' var IPython = (function (IPython) {'
94 params = params || {};
94 params = params || {};
95 if (!this.running) {
95 if (!this.running) {
96 var qs = $.param(params);
96 var qs = $.param(params);
97 var url = this.base_url + '?' + qs;
97 $.post(utils.url_join_encode(this.kernel_service_url) + '?' + qs,
98 $.post(url,
99 $.proxy(this._kernel_started, this),
98 $.proxy(this._kernel_started, this),
100 'json'
99 'json'
101 );
100 );
@@ -114,8 +113,7 b' var IPython = (function (IPython) {'
114 $([IPython.events]).trigger('status_restarting.Kernel', {kernel: this});
113 $([IPython.events]).trigger('status_restarting.Kernel', {kernel: this});
115 if (this.running) {
114 if (this.running) {
116 this.stop_channels();
115 this.stop_channels();
117 var url = utils.url_join_encode(this.kernel_url, "restart");
116 $.post(utils.url_join_encode(this.kernel_url, "restart"),
118 $.post(url,
119 $.proxy(this._kernel_started, this),
117 $.proxy(this._kernel_started, this),
120 'json'
118 'json'
121 );
119 );
@@ -133,8 +131,10 b' var IPython = (function (IPython) {'
133 var prot = location.protocol.replace('http', 'ws') + "//";
131 var prot = location.protocol.replace('http', 'ws') + "//";
134 ws_url = prot + location.host + ws_url;
132 ws_url = prot + location.host + ws_url;
135 }
133 }
136 this.ws_url = ws_url;
134 var parsed = utils.parse_url(ws_url);
137 this.kernel_url = utils.url_join_encode(this.base_url, this.kernel_id);
135 this.ws_host = parsed.protocol + "//" + parsed.host;
136 this.kernel_url = utils.url_path_join(this.kernel_service_url, this.kernel_id);
137 this.ws_url = utils.url_path_join(parsed.pathname, this.kernel_url);
138 this.start_channels();
138 this.start_channels();
139 };
139 };
140
140
@@ -155,12 +155,18 b' var IPython = (function (IPython) {'
155 Kernel.prototype.start_channels = function () {
155 Kernel.prototype.start_channels = function () {
156 var that = this;
156 var that = this;
157 this.stop_channels();
157 this.stop_channels();
158 var ws_url = this.ws_url + this.kernel_url;
158 console.log("Starting WebSockets:", this.ws_host + this.ws_url);
159 console.log("Starting WebSockets:", ws_url);
159 this.shell_channel = new this.WebSocket(
160 this.shell_channel = new this.WebSocket(ws_url + "/shell");
160 this.ws_host + utils.url_join_encode(this.ws_url, "shell")
161 this.stdin_channel = new this.WebSocket(ws_url + "/stdin");
161 );
162 this.iopub_channel = new this.WebSocket(ws_url + "/iopub");
162 this.stdin_channel = new this.WebSocket(
163 this.ws_host + utils.url_join_encode(this.ws_url, "stdin")
164 );
165 this.iopub_channel = new this.WebSocket(
166 this.ws_host + utils.url_join_encode(this.ws_url, "iopub")
167 );
163
168
169 var ws_host_url = this.ws_host + this.ws_url;
164 var already_called_onclose = false; // only alert once
170 var already_called_onclose = false; // only alert once
165 var ws_closed_early = function(evt){
171 var ws_closed_early = function(evt){
166 if (already_called_onclose){
172 if (already_called_onclose){
@@ -168,7 +174,7 b' var IPython = (function (IPython) {'
168 }
174 }
169 already_called_onclose = true;
175 already_called_onclose = true;
170 if ( ! evt.wasClean ){
176 if ( ! evt.wasClean ){
171 that._websocket_closed(ws_url, true);
177 that._websocket_closed(ws_host_url, true);
172 }
178 }
173 };
179 };
174 var ws_closed_late = function(evt){
180 var ws_closed_late = function(evt){
@@ -177,7 +183,7 b' var IPython = (function (IPython) {'
177 }
183 }
178 already_called_onclose = true;
184 already_called_onclose = true;
179 if ( ! evt.wasClean ){
185 if ( ! evt.wasClean ){
180 that._websocket_closed(ws_url, false);
186 that._websocket_closed(ws_host_url, false);
181 }
187 }
182 };
188 };
183 var channels = [this.shell_channel, this.iopub_channel, this.stdin_channel];
189 var channels = [this.shell_channel, this.iopub_channel, this.stdin_channel];
@@ -387,7 +393,7 b' var IPython = (function (IPython) {'
387 Kernel.prototype.interrupt = function () {
393 Kernel.prototype.interrupt = function () {
388 if (this.running) {
394 if (this.running) {
389 $([IPython.events]).trigger('status_interrupting.Kernel', {kernel: this});
395 $([IPython.events]).trigger('status_interrupting.Kernel', {kernel: this});
390 $.post(this.kernel_url + "/interrupt");
396 $.post(utils.url_join_encode(this.kernel_url, "interrupt"));
391 }
397 }
392 };
398 };
393
399
@@ -399,7 +405,7 b' var IPython = (function (IPython) {'
399 cache : false,
405 cache : false,
400 type : "DELETE"
406 type : "DELETE"
401 };
407 };
402 $.ajax(this.kernel_url, settings);
408 $.ajax(utils.url_join_encode(this.kernel_url), settings);
403 }
409 }
404 };
410 };
405
411
@@ -89,8 +89,8 b' var IPython = (function (IPython) {'
89 */
89 */
90 Session.prototype._handle_start_success = function (data, status, xhr) {
90 Session.prototype._handle_start_success = function (data, status, xhr) {
91 this.id = data.id;
91 this.id = data.id;
92 var base_url = utils.url_join_encode(this.base_kernel_url, "api/kernels");
92 var kernel_service_url = utils.url_path_join(this.base_kernel_url, "api/kernels");
93 this.kernel = new IPython.Kernel(base_url);
93 this.kernel = new IPython.Kernel(kernel_service_url);
94 this.kernel._kernel_started(data.kernel);
94 this.kernel._kernel_started(data.kernel);
95 };
95 };
96
96
General Comments 0
You need to be logged in to leave comments. Login now