]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
cStringIO's constructor uses a 16-bit encoding when given a unicode
authorBen Darnell <bdarnell@beaker.local>
Wed, 21 Apr 2010 20:57:05 +0000 (13:57 -0700)
committerBen Darnell <bdarnell@beaker.local>
Wed, 21 Apr 2010 20:57:05 +0000 (13:57 -0700)
string.  This is inconsistent with its write method, which encodes all
strings as ascii (and rejects unicode strings iff they have any
non-ascii characters).  This change uses utf-8 as the default encoding
when constructing cStringIO objects in tornado.

tornado/httpclient.py
tornado/wsgi.py

index ac4ad985a26b4f5f9f84acd009453a5bdb121a0b..c8702d209e0bdef056acfcfcec86472b28d6a2ba 100644 (file)
@@ -406,7 +406,7 @@ def _curl_setup_request(curl, request, buffer, headers):
 
     # Handle curl's cryptic options for every individual HTTP method
     if request.method in ("POST", "PUT"):
-        request_buffer =  cStringIO.StringIO(request.body)
+        request_buffer =  cStringIO.StringIO(request.body.encode('utf-8'))
         curl.setopt(pycurl.READFUNCTION, request_buffer.read)
         if request.method == "POST":
             def ioctl(cmd):
index e3f0a50b57ca3be0aad16d511cb3c0ae7121a013..07f4a2be8d336e0a7a48f56ab921956c39c8d331 100644 (file)
@@ -261,7 +261,7 @@ class WSGIContainer(object):
             "SERVER_PROTOCOL": request.version,
             "wsgi.version": (1, 0),
             "wsgi.url_scheme": request.protocol,
-            "wsgi.input": cStringIO.StringIO(request.body),
+            "wsgi.input": cStringIO.StringIO(request.body.encode('utf-8')),
             "wsgi.errors": sys.stderr,
             "wsgi.multithread": False,
             "wsgi.multiprocess": True,