Permalink
Browse files

Fix bugs in iframe workaround for POST requests

  • Loading branch information...
1 parent e2f8479 commit 9cfa65239c4cc29ae32cbdc8e89a2d09904000a6 @ihanson ihanson committed Mar 18, 2013
Showing with 5 additions and 5 deletions.
  1. +4 −4 handlers.py
  2. +1 −1 static/embedded_sagecell.js
View
@@ -100,10 +100,10 @@ def post(self):
logger.info("Starting session: %s"%timer)
kernel_id = yield gen.Task(km.new_session_async)
data = {"ws_url": ws_url, "kernel_id": kernel_id}
- if "frame" not in self.request.headers:
+ if "frame" not in self.request.arguments:
self.set_header("Access-Control-Allow-Origin", "*");
else:
- data = '<script>parent.postMessage(%s,"*");</script>' % (json.dumps(data),)
+ data = '<script>parent.postMessage(%r,"*");</script>' % (json.dumps(data),)
self.set_header("Content-Type", "text/html")
self.write(data)
self.finish()
@@ -177,10 +177,10 @@ def post(self):
retval["query"] = db.new_exec_msg(message)
except:
pass
- if "frame" not in self.request.headers:
+ if "frame" not in args:
self.set_header("Access-Control-Allow-Origin", "*");
else:
- retval = '<script>parent.postMessage(%s,"*");</script>' % (json.dumps(retval),)
+ retval = '<script>parent.postMessage(%r,"*");</script>' % (json.dumps(retval),)
self.set_header("Content-Type", "text/html")
self.write(retval)
self.finish()
@@ -595,7 +595,7 @@ sagecell.sendRequest = function (method, url, data, callback, files) {
form.style.display = iframe.style.display = "none";
document.body.appendChild(iframe);
document.body.appendChild(form);
- listen = function (evt) {
+ var listen = function (evt) {
if (evt.source === iframe.contentWindow &&
evt.origin + "/" === sagecell.URLs.root) {
if (window.removeEventListener) {

0 comments on commit 9cfa652

Please sign in to comment.