Code

Ticket #4710: is_secure.patch

File is_secure.patch, 877 bytes (added by SmileyChris, 7 years ago)

patch taking in Graham's suggestion of trying is_https() first

  • django/core/handlers/modpython.py

     
    4242        return '%s%s' % (self.path, self._req.args and ('?' + self._req.args) or '') 
    4343 
    4444    def is_secure(self): 
    45         # Note: modpython 3.2.10+ has req.is_https(), but we need to support previous versions 
    46         return 'HTTPS' in self._req.subprocess_env and self._req.subprocess_env['HTTPS'] == 'on' 
     45        try: 
     46            return self._req.is_https() 
     47        except AttributeError: 
     48            # mod_python versions <3.2.10 don't have req.is_https(). 
     49            return self._req.subprocess_env.get('HTTPS', '').lower() in ('on', '1') 
    4750 
    4851    def _load_post_and_files(self): 
    4952        "Populates self._post and self._files"