From 3e47f56344fc706116affeab45e8b340e883b1da Mon Sep 17 00:00:00 2001 From: blob8108 Date: Mon, 6 Jan 2014 11:37:08 +0000 Subject: 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 --- blockext/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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:] -- cgit v1.3.1