Merge pull request #493 from blink1073/allow-patches

Allow all Cross-Origin Methods
This commit is contained in:
Min RK 2015-09-25 00:00:15 +02:00
commit ec40a32ccb
7 changed files with 8 additions and 37 deletions

View File

@ -386,6 +386,13 @@ class APIHandler(IPythonHandler):
self.set_header('Content-Type', 'application/json') self.set_header('Content-Type', 'application/json')
return super(APIHandler, self).finish(*args, **kwargs) return super(APIHandler, self).finish(*args, **kwargs)
@web.authenticated
def options(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Headers', 'accept, content-type')
self.set_header('Access-Control-Allow-Methods',
'GET, PUT, PATCH, DELETE, OPTIONS')
self.finish()
class Template404(IPythonHandler): class Template404(IPythonHandler):
"""Render our 404 template""" """Render our 404 template"""

View File

@ -12,7 +12,6 @@ from ipython_genutils.py3compat import PY3
from ...base.handlers import APIHandler, json_errors from ...base.handlers import APIHandler, json_errors
class ConfigHandler(APIHandler): class ConfigHandler(APIHandler):
SUPPORTED_METHODS = ('GET', 'PUT', 'PATCH')
@web.authenticated @web.authenticated
@json_errors @json_errors

View File

@ -77,8 +77,6 @@ def validate_model(model, expect_content):
class ContentsHandler(APIHandler): class ContentsHandler(APIHandler):
SUPPORTED_METHODS = (u'GET', u'PUT', u'PATCH', u'POST', u'DELETE')
def location_url(self, path): def location_url(self, path):
"""Return the full URL location of a file. """Return the full URL location of a file.
@ -259,8 +257,6 @@ class ContentsHandler(APIHandler):
class CheckpointsHandler(APIHandler): class CheckpointsHandler(APIHandler):
SUPPORTED_METHODS = ('GET', 'POST')
@web.authenticated @web.authenticated
@json_errors @json_errors
@gen.coroutine @gen.coroutine
@ -288,8 +284,6 @@ class CheckpointsHandler(APIHandler):
class ModifyCheckpointsHandler(APIHandler): class ModifyCheckpointsHandler(APIHandler):
SUPPORTED_METHODS = ('POST', 'DELETE')
@web.authenticated @web.authenticated
@json_errors @json_errors
@gen.coroutine @gen.coroutine

View File

@ -51,8 +51,6 @@ class MainKernelHandler(APIHandler):
class KernelHandler(APIHandler): class KernelHandler(APIHandler):
SUPPORTED_METHODS = ('DELETE', 'GET', 'OPTIONS')
@web.authenticated @web.authenticated
@json_errors @json_errors
def get(self, kernel_id): def get(self, kernel_id):
@ -69,12 +67,6 @@ class KernelHandler(APIHandler):
self.set_status(204) self.set_status(204)
self.finish() self.finish()
@web.authenticated
@json_errors
def options(self, kernel_id):
self.set_header('Access-Control-Allow-Headers', 'accept, content-type')
self.finish()
class KernelActionHandler(APIHandler): class KernelActionHandler(APIHandler):
@ -92,12 +84,6 @@ class KernelActionHandler(APIHandler):
self.write(json.dumps(model)) self.write(json.dumps(model))
self.finish() self.finish()
@web.authenticated
@json_errors
def options(self, kernel_id, action):
self.set_header('Access-Control-Allow-Headers', 'accept, content-type')
self.finish()
class ZMQChannelsHandler(AuthenticatedZMQStreamHandler): class ZMQChannelsHandler(AuthenticatedZMQStreamHandler):

View File

@ -44,7 +44,6 @@ def kernelspec_model(handler, name):
return d return d
class MainKernelSpecHandler(APIHandler): class MainKernelSpecHandler(APIHandler):
SUPPORTED_METHODS = ('GET', 'OPTIONS')
@web.authenticated @web.authenticated
@json_errors @json_errors
@ -64,14 +63,8 @@ class MainKernelSpecHandler(APIHandler):
self.set_header("Content-Type", 'application/json') self.set_header("Content-Type", 'application/json')
self.finish(json.dumps(model)) self.finish(json.dumps(model))
@web.authenticated
@json_errors
def options(self):
self.finish()
class KernelSpecHandler(APIHandler): class KernelSpecHandler(APIHandler):
SUPPORTED_METHODS = ('GET',)
@web.authenticated @web.authenticated
@json_errors @json_errors

View File

@ -5,7 +5,6 @@ from tornado import web
from ...base.handlers import APIHandler, json_errors from ...base.handlers import APIHandler, json_errors
class NbconvertRootHandler(APIHandler): class NbconvertRootHandler(APIHandler):
SUPPORTED_METHODS = ('GET',)
@web.authenticated @web.authenticated
@json_errors @json_errors
@ -23,4 +22,4 @@ class NbconvertRootHandler(APIHandler):
default_handlers = [ default_handlers = [
(r"/api/nbconvert", NbconvertRootHandler), (r"/api/nbconvert", NbconvertRootHandler),
] ]

View File

@ -68,16 +68,9 @@ class SessionRootHandler(APIHandler):
self.set_status(201) self.set_status(201)
self.finish(json.dumps(model, default=date_default)) self.finish(json.dumps(model, default=date_default))
@web.authenticated
@json_errors
def options(self):
self.set_header('Access-Control-Allow-Headers', 'accept, content-type')
self.finish()
class SessionHandler(APIHandler): class SessionHandler(APIHandler):
SUPPORTED_METHODS = ('GET', 'PATCH', 'DELETE')
@web.authenticated @web.authenticated
@json_errors @json_errors
def get(self, session_id): def get(self, session_id):