Add x-session-id header to cors middleware.

And convert all simple quotes to double quotes.
remotes/origin/enhancement/email-actions
Andrey Antukh 2014-03-15 21:03:51 +01:00
parent 4b0bc5f8da
commit fe4ae3a90d
1 changed files with 8 additions and 7 deletions

View File

@ -5,11 +5,12 @@ import json
from django import http from django import http
COORS_ALLOWED_ORIGINS = '*' COORS_ALLOWED_ORIGINS = "*"
COORS_ALLOWED_METHODS = ['POST', 'GET', 'OPTIONS', 'PUT', 'DELETE', 'PATCH', 'HEAD'] COORS_ALLOWED_METHODS = ["POST", "GET", "OPTIONS", "PUT", "DELETE", "PATCH", "HEAD"]
COORS_ALLOWED_HEADERS = ['content-type', 'x-requested-with', COORS_ALLOWED_HEADERS = ["content-type", "x-requested-with",
'authorization', 'accept-encoding', "authorization", "accept-encoding",
'x-disable-pagination', 'x-host'] "x-disable-pagination", "x-host",
"x-session-id"]
COORS_ALLOWED_CREDENTIALS = True COORS_ALLOWED_CREDENTIALS = True
COORS_EXPOSE_HEADERS = ["x-pagination-count", "x-paginated", "x-paginated-by", COORS_EXPOSE_HEADERS = ["x-pagination-count", "x-paginated", "x-paginated-by",
"x-paginated-by", "x-pagination-current", "x-site-host", "x-paginated-by", "x-pagination-current", "x-site-host",
@ -24,10 +25,10 @@ class CoorsMiddleware(object):
response["Access-Control-Expose-Headers"] = ",".join(COORS_EXPOSE_HEADERS) response["Access-Control-Expose-Headers"] = ",".join(COORS_EXPOSE_HEADERS)
if COORS_ALLOWED_CREDENTIALS: if COORS_ALLOWED_CREDENTIALS:
response["Access-Control-Allow-Credentials"] = 'true' response["Access-Control-Allow-Credentials"] = "true"
def process_request(self, request): def process_request(self, request):
if 'HTTP_ACCESS_CONTROL_REQUEST_METHOD' in request.META: if "HTTP_ACCESS_CONTROL_REQUEST_METHOD" in request.META:
response = http.HttpResponse() response = http.HttpResponse()
self._populate_response(response) self._populate_response(response)
return response return response