[MERGE] merge trunk into local branch
bzr revid: ged@openerp.com-20140130155158-zwddmty5a79mcn90
This commit is contained in:
@@ -410,6 +410,19 @@ class HttpRequest(WebRequest):
|
||||
self.params = params
|
||||
|
||||
def dispatch(self):
|
||||
# TODO: refactor this correctly. This is a quick fix for pos demo.
|
||||
if request.httprequest.method == 'OPTIONS' and request.func.cors:
|
||||
response = werkzeug.wrappers.Response(status=200)
|
||||
response.headers.set('Access-Control-Allow-Origin', request.func.cors)
|
||||
methods = 'GET, POST'
|
||||
if request.func_request_type == 'json':
|
||||
methods = 'POST'
|
||||
elif request.func.methods:
|
||||
methods = ', '.join(request.func.methods)
|
||||
response.headers.set('Access-Control-Allow-Methods', methods)
|
||||
response.headers.set('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')
|
||||
return response
|
||||
|
||||
r = self._call_function(**self.params)
|
||||
if not r:
|
||||
r = werkzeug.wrappers.Response(status=204) # no content
|
||||
|
||||
Reference in New Issue
Block a user