Minor cleanup in the WSGI handler.

This commit is contained in:
Aymeric Augustin 2013-09-07 10:25:16 -05:00
parent 4e88d106dc
commit ae7f9afaf6
1 changed files with 3 additions and 3 deletions

View File

@ -93,7 +93,7 @@ class WSGIRequest(http.HttpRequest):
self.META['PATH_INFO'] = path_info self.META['PATH_INFO'] = path_info
self.META['SCRIPT_NAME'] = script_name self.META['SCRIPT_NAME'] = script_name
self.method = environ['REQUEST_METHOD'].upper() self.method = environ['REQUEST_METHOD'].upper()
_, content_params = self._parse_content_type(self.META.get('CONTENT_TYPE', '')) _, content_params = self._parse_content_type(environ.get('CONTENT_TYPE', ''))
if 'charset' in content_params: if 'charset' in content_params:
try: try:
codecs.lookup(content_params['charset']) codecs.lookup(content_params['charset'])
@ -103,7 +103,7 @@ class WSGIRequest(http.HttpRequest):
self.encoding = content_params['charset'] self.encoding = content_params['charset']
self._post_parse_error = False self._post_parse_error = False
try: try:
content_length = int(self.environ.get('CONTENT_LENGTH')) content_length = int(environ.get('CONTENT_LENGTH'))
except (ValueError, TypeError): except (ValueError, TypeError):
content_length = 0 content_length = 0
self._stream = LimitedStream(self.environ['wsgi.input'], content_length) self._stream = LimitedStream(self.environ['wsgi.input'], content_length)
@ -111,7 +111,7 @@ class WSGIRequest(http.HttpRequest):
self.resolver_match = None self.resolver_match = None
def _is_secure(self): def _is_secure(self):
return 'wsgi.url_scheme' in self.environ and self.environ['wsgi.url_scheme'] == 'https' return self.environ.get('wsgi.url_scheme') == 'https'
def _parse_content_type(self, ctype): def _parse_content_type(self, ctype):
""" """