From: Ben Darnell Date: Wed, 21 Apr 2010 21:17:22 +0000 (-0700) Subject: Use escape.utf8() instead of .encode('utf-8') so we don't double-encode X-Git-Tag: v1.0.0~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f7c9a38ff4d07fc79101bb05809cecd2efb8d6c;p=thirdparty%2Ftornado.git Use escape.utf8() instead of .encode('utf-8') so we don't double-encode --- diff --git a/tornado/httpclient.py b/tornado/httpclient.py index c8702d209..76e18bb5b 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -21,6 +21,7 @@ import collections import cStringIO import email.utils import errno +import escape import functools import httplib import ioloop @@ -406,7 +407,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.encode('utf-8')) + request_buffer = cStringIO.StringIO(escape.utf8(request.body)) curl.setopt(pycurl.READFUNCTION, request_buffer.read) if request.method == "POST": def ioctl(cmd): diff --git a/tornado/wsgi.py b/tornado/wsgi.py index 07f4a2be8..c14bab9ca 100644 --- a/tornado/wsgi.py +++ b/tornado/wsgi.py @@ -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.encode('utf-8')), + "wsgi.input": cStringIO.StringIO(escape.utf8(request.body)), "wsgi.errors": sys.stderr, "wsgi.multithread": False, "wsgi.multiprocess": True,