parent
b13bbe9abb
commit
47cbd5c2d2
|
@ -65,11 +65,20 @@ class Application(object):
|
||||||
else:
|
else:
|
||||||
return HTTPNotFound()(environ, start_response)
|
return HTTPNotFound()(environ, start_response)
|
||||||
|
|
||||||
|
request = webob.Request(environ)
|
||||||
|
request.config = self.config.copy()
|
||||||
|
|
||||||
|
# Sometimes, hacky applications will try to "emulate" some HTTP
|
||||||
|
# method like POST or DELETE by specifying an _method parameter
|
||||||
|
# in a POST request.
|
||||||
|
if request.method == 'POST' and '_method' in request.POST:
|
||||||
|
request.method = request.POST.pop('_method')
|
||||||
|
|
||||||
allowed_methods = getattr(func, 'allowed_methods',
|
allowed_methods = getattr(func, 'allowed_methods',
|
||||||
self.DEFAULT_ALLOWED_METHODS)
|
self.DEFAULT_ALLOWED_METHODS)
|
||||||
if environ['REQUEST_METHOD'] not in allowed_methods:
|
if request.method not in allowed_methods:
|
||||||
allow_header = {'Allow': ', '.join(allowed_methods)}
|
allow_header = {'Allow': ', '.join(allowed_methods)}
|
||||||
if environ['REQUEST_METHOD'] == 'OPTIONS':
|
if request.method == 'OPTIONS':
|
||||||
def options_response(request, *args, **kwargs):
|
def options_response(request, *args, **kwargs):
|
||||||
response = request.ResponseClass()
|
response = request.ResponseClass()
|
||||||
response.headers = allow_header
|
response.headers = allow_header
|
||||||
|
@ -78,9 +87,6 @@ class Application(object):
|
||||||
return HTTPMethodNotAllowed(headers=allow_header)(environ,
|
return HTTPMethodNotAllowed(headers=allow_header)(environ,
|
||||||
start_response)
|
start_response)
|
||||||
|
|
||||||
request = webob.Request(environ)
|
|
||||||
request.config = self.config.copy()
|
|
||||||
|
|
||||||
start_response_wrapper = StartResponseWrapper(start_response)
|
start_response_wrapper = StartResponseWrapper(start_response)
|
||||||
request.start_response = start_response_wrapper
|
request.start_response = start_response_wrapper
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue