Changeset 47
- Timestamp:
- 10/06/06 20:10:51 (2 years ago)
- Files:
-
- 1 modified
-
django/trunk/middleware/sslmiddleware.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
django/trunk/middleware/sslmiddleware.py
r46 r47 11 11 https-less counterpart if needed). 12 12 """ 13 __version__ = "1. 0"13 __version__ = "1.1" 14 14 __license__ = "Python" 15 15 __copyright__ = "Copyright (C) 2006, Antonio Cavedoni" 16 16 __author__ = "Antonio Cavedoni <http://cavedoni.com/>" 17 __contributors__ = ["Stefano J. Attardi <http://attardi.org/>"] 17 __contributors__ = [ 18 "Stefano J. Attardi <http://attardi.org/>", 19 "Carlo C8E Miron" 20 ] 18 21 19 22 from django.conf import settings … … 27 30 if request.path.startswith("/%s" % path): 28 31 if not request.is_secure(): 29 # Redirect to https://32 # Should be SSL but it isn't, redirect! 30 33 return self._redirect(request, "https") 31 34 else: … … 35 38 if _to_redir: 36 39 if request.is_secure(): 40 # Shouldn't be SSL but it is, redirect! 37 41 return self._redirect(request, "http") 38 42 … … 42 46 if request.GET: 43 47 newurl += '?' + request.GET.urlencode() 48 if settings.DEBUG and request.method == 'POST': 49 raise RuntimeError, """ 50 Django can't redirect to the %(protocol)s URL you requested while maintaining 51 POST data. Change your form to point to %(uri)s (dont't forget to specify the 52 %(protocol)s or remove the requested path from the HTTPS_PATHS tuple in the 53 project settings""" % {'uri': newurl, 'protocol': protocol.upper()} 44 54 return HttpResponseRedirect(newurl)