More CORS support

This adds CORS preflight support to the test server.

Change-Id: I0029e4f8a7056e86dc8a2b6df6f7d935f9ee772d
This commit is contained in:
Kevin Fox 2015-08-31 13:59:31 -07:00
parent 0b136c764c
commit 2f200e65b9
2 changed files with 12 additions and 0 deletions

View File

View File

@ -18,10 +18,22 @@ import SocketServer
class AllowOriginRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
print("App Catalog Versions:",
self.headers.get('X-App-Catalog-Versions', ''))
return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
def end_headers(self):
self.send_header("Access-Control-Allow-Origin", "*")
SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)
def do_OPTIONS(self):
self.send_response(200)
self.send_header("Access-Control-Allow-Origin", "*")
self.send_header("Access-Control-Allow-Headers",
"X-App-Catalog-Versions")
self.send_header("Allow", "GET")
if __name__ == '__main__':
PORT = 18001
httpd = SocketServer.TCPServer(("", PORT), AllowOriginRequestHandler)