diff -uprN django.orig/core/handlers/modpython.py django/core/handlers/modpython.py
old
|
new
|
class ModPythonRequest(http.HttpRequest)
|
43 | 43 | |
44 | 44 | def is_secure(self): |
45 | 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' |
| 46 | return self._req.subprocess_env.has_key('HTTPS') and self._req.subprocess_env['HTTPS'] == 'on' |
47 | 47 | |
48 | 48 | def _load_post_and_files(self): |
49 | 49 | "Populates self._post and self._files" |
50 | | if 'content-type' in self._req.headers_in and self._req.headers_in['content-type'].startswith('multipart'): |
| 50 | if self._req.headers_in.has_key('content-type') and self._req.headers_in['content-type'].startswith('multipart'): |
51 | 51 | self._post, self._files = http.parse_file_upload(self._req.headers_in, self.raw_post_data) |
52 | 52 | else: |
53 | 53 | self._post, self._files = http.QueryDict(self.raw_post_data, encoding=self._encoding), datastructures.MultiValueDict() |
… |
… |
class ModPythonRequest(http.HttpRequest)
|
75 | 75 | |
76 | 76 | def _get_cookies(self): |
77 | 77 | if not hasattr(self, '_cookies'): |
78 | | self._cookies = http.parse_cookie(self._req.headers_in.get('cookie', '')) |
| 78 | if not self._req.headers_in.has_key('cookie'): |
| 79 | self._req.headers_in['cookie'] = '' |
| 80 | self._cookies = http.parse_cookie(self._req.headers_in['cookie']) |
79 | 81 | return self._cookies |
80 | 82 | |
81 | 83 | def _set_cookies(self, cookies): |
… |
… |
class ModPythonRequest(http.HttpRequest)
|
89 | 91 | def _get_meta(self): |
90 | 92 | "Lazy loader that returns self.META dictionary" |
91 | 93 | if not hasattr(self, '_meta'): |
| 94 | if hasattr(self._req, 'ap_auth_type'): |
| 95 | auth_type = self._req.ap_auth_type |
| 96 | else: |
| 97 | auth_type = None |
| 98 | if hasattr(self._req, 'user'): |
| 99 | user = self._req.user |
| 100 | else: |
| 101 | user = None |
92 | 102 | self._meta = { |
93 | | 'AUTH_TYPE': self._req.ap_auth_type, |
| 103 | 'AUTH_TYPE': auth_type, |
94 | 104 | 'CONTENT_LENGTH': self._req.clength, # This may be wrong |
95 | 105 | 'CONTENT_TYPE': self._req.content_type, # This may be wrong |
96 | 106 | 'GATEWAY_INTERFACE': 'CGI/1.1', |
… |
… |
class ModPythonRequest(http.HttpRequest)
|
100 | 110 | 'REMOTE_ADDR': self._req.connection.remote_ip, |
101 | 111 | 'REMOTE_HOST': None, # DNS lookups not supported |
102 | 112 | 'REMOTE_IDENT': self._req.connection.remote_logname, |
103 | | 'REMOTE_USER': self._req.user, |
| 113 | 'REMOTE_USER': user, |
104 | 114 | 'REQUEST_METHOD': self._req.method, |
105 | 115 | 'SCRIPT_NAME': None, # Not supported |
106 | 116 | 'SERVER_NAME': self._req.server.server_hostname, |
… |
… |
class ModPythonRequest(http.HttpRequest)
|
108 | 118 | 'SERVER_PROTOCOL': self._req.protocol, |
109 | 119 | 'SERVER_SOFTWARE': 'mod_python' |
110 | 120 | } |
111 | | for key, value in self._req.headers_in.items(): |
112 | | key = 'HTTP_' + key.upper().replace('-', '_') |
113 | | self._meta[key] = value |
| 121 | for key in self._req.headers_in.keys(): |
| 122 | meta_key = 'HTTP_' + key.upper().replace('-', '_') |
| 123 | self._meta[meta_key] = self._req.headers_in[key] |
114 | 124 | return self._meta |
115 | 125 | |
116 | 126 | def _get_raw_post_data(self): |
… |
… |
class ModPythonHandler(BaseHandler):
|
165 | 175 | for c in response.cookies.values(): |
166 | 176 | req.headers_out.add('Set-Cookie', c.output(header='')) |
167 | 177 | req.status = response.status_code |
| 178 | if hasattr(req, 'send_http_header'): |
| 179 | req.send_http_header() |
168 | 180 | try: |
169 | 181 | for chunk in response: |
170 | 182 | req.write(chunk) |