thirdparty/google_appengine/google/appengine/ext/webapp/__init__.py
changeset 297 35211afcd563
parent 149 f2e327a7c5de
child 828 f5fd65cc3bf3
--- a/thirdparty/google_appengine/google/appengine/ext/webapp/__init__.py	Fri Oct 10 06:56:56 2008 +0000
+++ b/thirdparty/google_appengine/google/appengine/ext/webapp/__init__.py	Fri Oct 10 13:14:24 2008 +0000
@@ -70,6 +70,7 @@
 import wsgiref.util
 
 RE_FIND_GROUPS = re.compile('\(.*?\)')
+_CHARSET_RE = re.compile(r';\s*charset=([^;\s]*)', re.I)
 
 class Error(Exception):
   """Base of all exceptions in the webapp module."""
@@ -107,8 +108,10 @@
     Args:
       environ: A WSGI-compliant environment dictionary.
     """
-    charset = webob.NoDefault
-    if environ.get('CONTENT_TYPE', '').find('charset') == -1:
+    match = _CHARSET_RE.search(environ.get('CONTENT_TYPE', ''))
+    if match:
+      charset = match.group(1).lower()
+    else:
       charset = 'utf-8'
 
     webob.Request.__init__(self, environ, charset=charset,