<s> import re <EOL> from django . utils . text import compress_string <EOL> from django . utils . cache import patch_vary_headers <EOL> from django import http <EOL> try : <EOL> import settings <EOL> XS_SHARING_ALLOWED_ORIGINS = settings . XS_SHARING_ALLOWED_ORIGINS <EOL> XS_SHARING_ALLOWED_METHODS = settings . XS_SHARING_ALLOWED_METHODS <EOL> except : <EOL> XS_SHARING_ALLOWED_ORIGINS = '<STR_LIT:*>' <EOL> XS_SHARING_ALLOWED_METHODS = [ '<STR_LIT:POST>' , '<STR_LIT:GET>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> class XsSharing ( object ) : <EOL> """<STR_LIT>""" <EOL> def process_request ( self , request ) : <EOL> if '<STR_LIT>' in request . META : <EOL> response = http . HttpResponse ( ) <EOL> response [ '<STR_LIT>' ] = XS_SHARING_ALLOWED_ORIGINS <EOL> response [ '<STR_LIT>' ] = "<STR_LIT:U+002C>" . join ( XS_SHARING_ALLOWED_METHODS ) <EOL> return response <EOL> return None <EOL> def process_response ( self , request , response ) : <EOL> if response . has_header ( '<STR_LIT>' ) : <EOL> return response <EOL> response [ '<STR_LIT>' ] = XS_SHARING_ALLOWED_ORIGINS <EOL> response [ '<STR_LIT>' ] = "<STR_LIT:U+002C>" . join ( XS_SHARING_ALLOWED_METHODS ) <EOL> return response </s>
