web/http_headers.py
changeset 10603 65ad6980976e
parent 10594 6a55853f14c9
child 10612 84468b90e9c1
equal deleted inserted replaced
10602:4845012cfc8e 10603:65ad6980976e
     4 
     4 
     5 import time
     5 import time
     6 from calendar import timegm
     6 from calendar import timegm
     7 import base64
     7 import base64
     8 import re
     8 import re
     9 import urlparse
     9 
       
    10 from six.moves.urllib.parse import urlparse
       
    11 
    10 
    12 
    11 def dashCapitalize(s):
    13 def dashCapitalize(s):
    12     ''' Capitalize a string, making sure to treat - as a word seperator '''
    14     ''' Capitalize a string, making sure to treat - as a word seperator '''
    13     return '-'.join([ x.capitalize() for x in s.split('-')])
    15     return '-'.join([ x.capitalize() for x in s.split('-')])
    14 
    16 
   396 
   398 
   397 def parseAllowOrigin(origin):
   399 def parseAllowOrigin(origin):
   398     """Ensure origin is a valid URL-base stuff, or null"""
   400     """Ensure origin is a valid URL-base stuff, or null"""
   399     if origin == 'null':
   401     if origin == 'null':
   400         return origin
   402         return origin
   401     p = urlparse.urlparse(origin)
   403     p = urlparse(origin)
   402     if p.params or p.query or p.username or p.path not in ('', '/'):
   404     if p.params or p.query or p.username or p.path not in ('', '/'):
   403         raise ValueError('Incorrect Accept-Control-Allow-Origin value %s' % origin)
   405         raise ValueError('Incorrect Accept-Control-Allow-Origin value %s' % origin)
   404     if p.scheme not in ('http', 'https'):
   406     if p.scheme not in ('http', 'https'):
   405         raise ValueError('Unsupported Accept-Control-Allow-Origin URL scheme %s' % origin)
   407         raise ValueError('Unsupported Accept-Control-Allow-Origin URL scheme %s' % origin)
   406     if not p.netloc:
   408     if not p.netloc: