always announce CORS, fix 3218e16
This commit is contained in:
parent
27022af1e6
commit
0f7516edb4
@ -68,7 +68,7 @@ class Isso(object):
|
|||||||
def __init__(self, dbpath, secret, origin, max_age, passphrase):
|
def __init__(self, dbpath, secret, origin, max_age, passphrase):
|
||||||
|
|
||||||
self.DBPATH = dbpath
|
self.DBPATH = dbpath
|
||||||
self.ORIGIN = utils.normalize(origin)
|
self.ORIGIN = origin
|
||||||
self.PASSPHRASE = passphrase
|
self.PASSPHRASE = passphrase
|
||||||
self.MAX_AGE = max_age
|
self.MAX_AGE = max_age
|
||||||
|
|
||||||
@ -103,10 +103,7 @@ class Isso(object):
|
|||||||
except NotFound as e:
|
except NotFound as e:
|
||||||
return Response('Not Found', 404)
|
return Response('Not Found', 404)
|
||||||
except MethodNotAllowed:
|
except MethodNotAllowed:
|
||||||
return Response("", 200, headers={
|
return Response("Yup.", 200)
|
||||||
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
|
|
||||||
"Access-Control-Allow-Headers": "Origin, Content-Type"
|
|
||||||
})
|
|
||||||
except HTTPException as e:
|
except HTTPException as e:
|
||||||
return e
|
return e
|
||||||
except InternalServerError as e:
|
except InternalServerError as e:
|
||||||
@ -114,6 +111,11 @@ class Isso(object):
|
|||||||
|
|
||||||
def wsgi_app(self, environ, start_response):
|
def wsgi_app(self, environ, start_response):
|
||||||
response = self.dispatch(Request(environ), start_response)
|
response = self.dispatch(Request(environ), start_response)
|
||||||
|
if hasattr(response, 'headers'):
|
||||||
|
response.headers["Access-Control-Allow-Origin"] = self.ORIGIN.rstrip('/')
|
||||||
|
response.headers["Access-Control-Allow-Headers"] = "Origin, Content-Type"
|
||||||
|
response.headers["Access-Control-Allow-Credentials"] = "true"
|
||||||
|
response.headers["Access-Control-Allow-Methods"] = "GET, POST, PUT, DELETE"
|
||||||
return response(environ, start_response)
|
return response(environ, start_response)
|
||||||
|
|
||||||
def __call__(self, environ, start_response):
|
def __call__(self, environ, start_response):
|
||||||
|
@ -33,7 +33,7 @@ class IssoEncoder(json.JSONEncoder):
|
|||||||
def urlexists(host, path):
|
def urlexists(host, path):
|
||||||
with contextlib.closing(httplib.HTTPConnection(host)) as con:
|
with contextlib.closing(httplib.HTTPConnection(host)) as con:
|
||||||
try:
|
try:
|
||||||
con.request('HEAD', path)
|
con.request('HEAD', normalize(path))
|
||||||
except socket.error:
|
except socket.error:
|
||||||
return False
|
return False
|
||||||
return con.getresponse().status == 200
|
return con.getresponse().status == 200
|
||||||
|
Loading…
Reference in New Issue
Block a user