Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleaned up WSGIRequestHandler get_environ to be Python 3 compatible

headers.type/typeheader attributes are gone in Python 3. Thanks
Vinay Sajip for the inspiration of his Python 3 branch.
  • Loading branch information...
commit 91727c76cda3f8bf286ee69652bc3625f150f6e7 1 parent 02eca6c
@claudep claudep authored
Showing with 12 additions and 14 deletions.
  1. +12 −14 django/core/servers/basehttp.py
View
26 django/core/servers/basehttp.py
@@ -146,25 +146,23 @@ def get_environ(self):
env['PATH_INFO'] = urllib.unquote(path)
env['QUERY_STRING'] = query
env['REMOTE_ADDR'] = self.client_address[0]
+ env['CONTENT_TYPE'] = self.headers.get('content-type', 'text/plain')
- if self.headers.typeheader is None:
- env['CONTENT_TYPE'] = self.headers.type
- else:
- env['CONTENT_TYPE'] = self.headers.typeheader
-
- length = self.headers.getheader('content-length')
+ length = self.headers.get('content-length')
if length:
env['CONTENT_LENGTH'] = length
- for h in self.headers.headers:
- k,v = h.split(':',1)
- k=k.replace('-','_').upper(); v=v.strip()
- if k in env:
- continue # skip content length, type,etc.
- if 'HTTP_'+k in env:
- env['HTTP_'+k] += ','+v # comma-separate multiple headers
+ for key, value in self.headers.items():
+ key = key.replace('-','_').upper()
+ value = value.strip()
+ if key in env:
+ # Skip content length, type, etc.
+ continue
+ if 'HTTP_' + key in env:
+ # Comma-separate multiple headers
+ env['HTTP_' + key] += ',' + value
else:
- env['HTTP_'+k] = v
+ env['HTTP_' + key] = value
return env
def log_message(self, format, *args):

0 comments on commit 91727c7

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