def set_cors_headers_for_response(response):
 if (config.get(u'ckan.cors.origin_allow_all') and request.headers.get(u'Origin')):
  cors_origin_allowed = None
  if asbool(config.get(u'ckan.cors.origin_allow_all')):
   cors_origin_allowed = u'*'
  elif (config.get(u'ckan.cors.origin_whitelist') and (request.headers.get(u'Origin') in config[u'ckan.cors.origin_whitelist'].split(u' '))):
   cors_origin_allowed = request.headers.get(u'Origin')
  if (cors_origin_allowed is not None):
   response.headers[u'Access-Control-Allow-Origin'] = cors_origin_allowed
   response.headers[u'Access-Control-Allow-Methods'] = u'POST, PUT, GET, DELETE, OPTIONS'
   response.headers[u'Access-Control-Allow-Headers'] = u'X-CKAN-API-KEY, Authorization, Content-Type'
 return response

def set_cors_headers_for_response ( response ) : if ( config . get ( u'ckan.cors.origin_allow_all' ) and request . headers . get ( u'Origin' ) ) : cors_origin_allowed = None if asbool ( config . get ( u'ckan.cors.origin_allow_all' ) ) : cors_origin_allowed = u'*' elif ( config . get ( u'ckan.cors.origin_whitelist' ) and ( request . headers . get ( u'Origin' ) in config [ u'ckan.cors.origin_whitelist' ] . split ( u' ' ) ) ) : cors_origin_allowed = request . headers . get ( u'Origin' ) if ( cors_origin_allowed is not None ) : response . headers [ u'Access-Control-Allow-Origin' ] = cors_origin_allowed response . headers [ u'Access-Control-Allow-Methods' ] = u'POST, PUT, GET, DELETE, OPTIONS' response . headers [ u'Access-Control-Allow-Headers' ] = u'X-CKAN-API-KEY, Authorization, Content-Type' return response
set up access control allow headers if either origin_allow_all is true .