Commits

jayd3e  committed 8002703

Trying to fix as_string()

  • Participants
  • Parent commits cc2bbd9

Comments (0)

Files changed (1)

File webob/request.py

         headers = list(self.headers.items())
         parts += map('%s: %s'.__mod__, sorted(headers))
         if body:
-            parts += '', body.decode('UTF-8')
+            parts.append(body.decode('UTF-8'))
         return '\r\n'.join(parts)
 
     __str__ = as_string
     env['REQUEST_METHOD'] = 'POST'
     if hasattr(data, 'items'):
         data = list(data.items())
-    if not isinstance(data, six.binary_type):
+    if not isinstance(data, str):
         data = urllib.parse.urlencode(data)
         data = data.encode('iso-8859-1')
     env['wsgi.input'] = BytesIO(data)
     env['webob.is_body_seekable'] = True
-    env['CONTENT_LENGTH'] = six.binary_type(len(data))
+    env['CONTENT_LENGTH'] = str(len(data))
     env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
 
 
             if self.content_type.lower().startswith('application/x-www-form-urlencoded'):
                 items = self.vars.items()
                 body = urllib.parse.urlencode(list(items))
-                self._body = body.encode('iso-8859-1')
+                self._body = body.encode('UTF-8')
             elif self.content_type.lower().startswith('multipart/form-data'):
                 body = _encode_multipart(self.vars, self.content_type)
-                self._body = body.encode('iso-8859-1')
+                self._body = body.encode('UTF-8')
             else:
                 assert 0, ('Bad content type: %r' % self.content_type)
         return self._body
             lines.append(ct)
         lines.append('')
         if hasattr(value, 'value'):
-            v = str(value.value)
+            v = value.value
+            if not isinstance(value, str):
+                v = value.value.decode('UTF-8')
         else:
-            v = str(value)
+            v = value
+            if not isinstance(value, str):
+                v = value.decode('UTF-8')
         lines.append(v)
     lines.append('--%s--' % boundary)
     return '\r\n'.join(lines)
     def _iteritems(obj):
         return obj.items()
     def _iterkeys(obj):
-        return obj.items()
+        return obj.keys()
     def _itervalues(obj):
         return obj.values()
 else: