Skip to content
Browse files

enforce a canonical domain

  • Loading branch information...
1 parent b5822c0 commit 69eb70887445e707c5e723600ad19474b4d3b07f @rctay committed May 22, 2010
Showing with 9 additions and 0 deletions.
  1. +9 −0 static.py
View
9 static.py
@@ -120,6 +120,14 @@ def _tx():
content.delete()
return db.run_in_transaction(_tx)
+def canonical_redirect(func):
+ def _dec(self, path):
+ if not self.request.host == config.host:
+ self.redirect("%s://%s%s" % (self.request.scheme, config.host, path), True)
+ else:
+ func(self, path)
+ return _dec
+
class StaticContentHandler(webapp.RequestHandler):
def output_content(self, content, serve=True):
if content.content_type:
@@ -136,6 +144,7 @@ def output_content(self, content, serve=True):
else:
self.response.set_status(304)
+ @canonical_redirect
def get(self, path):
if not path.startswith(config.url_prefix):
if path not in ROOT_ONLY_FILES:

0 comments on commit 69eb708

Please sign in to comment.
Something went wrong with that request. Please try again.