summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblob8108 <spaaam42@gmail.com>2014-01-06 11:37:08 +0000
committerblob8108 <spaaam42@gmail.com>2014-01-06 11:37:08 +0000
commit3e47f56344fc706116affeab45e8b340e883b1da (patch)
tree88af64ecaeafe64912d5d53be9f91095ea1c2172
parent03b0254e575c2ac9cd8a3f7076c97ce9e4e93989 (diff)
downloadblockext-3e47f56344fc706116affeab45e8b340e883b1da.tar.gz
blockext-3e47f56344fc706116affeab45e8b340e883b1da.zip
Don't recognise Snap! as a browser
Uses "X-Application" header in anticipation of https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/pull/295 Fixes #1
-rw-r--r--blockext/__init__.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/blockext/__init__.py b/blockext/__init__.py
index 7b2a36e..6f3eede 100644
--- a/blockext/__init__.py
+++ b/blockext/__init__.py
@@ -74,8 +74,16 @@ class Blockext(BaseHTTPRequestHandler):
handlers[name] = func
return handlers
+ def do_OPTIONS(self):
+ self.send_response(200)
+ self.send_header("Access-Control-Allow-Origin", "*")
+ self.send_header("Access-Control-Allow-Headers",
+ "X-Requested-With, X-Application, Accept")
+ self.end_headers()
+
def do_GET(self):
- is_browser = "text/html" in self.headers.get("Accept", "")
+ is_browser = ("text/html" in self.headers.get("Accept", "") and
+ "Snap!" not in self.headers.get("X-Application", ""))
mime_type = "text/plain"
path = self.path.split("/")[1:]