mirror of https://github.com/zulip/zulip.git
Return correct OPTIONS in rest_dispatch
(imported from commit 095175cad4df982d2bf5603f3b927a3aa6d7f41f)
This commit is contained in:
parent
a54d50ab2d
commit
5147b52267
|
@ -5,7 +5,7 @@ from django.views.decorators.csrf import csrf_exempt, csrf_protect
|
|||
from zerver.decorator import authenticated_json_view, authenticated_rest_api_view, \
|
||||
process_as_post, JsonableError
|
||||
from zerver.lib.response import json_method_not_allowed, json_unauthorized, json_unhandled_exception
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.conf import settings
|
||||
|
||||
import logging
|
||||
|
@ -40,6 +40,12 @@ def rest_dispatch(request, globals_list, **kwargs):
|
|||
supported_methods[arg] = kwargs[arg]
|
||||
del kwargs[arg]
|
||||
|
||||
if request.method == 'OPTIONS':
|
||||
response = HttpResponse(status=204) # No content
|
||||
response['Allow'] = ', '.join(supported_methods.keys())
|
||||
response['Content-Length'] = "0"
|
||||
return response
|
||||
|
||||
# Override requested method if magic method=??? parameter exists
|
||||
method_to_use = request.method
|
||||
if request.POST and 'method' in request.POST:
|
||||
|
|
Loading…
Reference in New Issue