From: Kenneth Reitz Date: Mon, 26 Sep 2011 04:53:43 +0000 (-0400) Subject: send file name X-Git-Tag: v0.8.0~94^2~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8ac2fe6eb170633b8b42e1af9b86e94729b339c2;p=services%2Fpython-requests.git send file name --- diff --git a/requests/models.py b/requests/models.py index 39d95e6..01184f9 100644 --- a/requests/models.py +++ b/requests/models.py @@ -248,7 +248,7 @@ class Request(object): if not isinstance(self.data, basestring): fields = self.data.copy() for (k, v) in self.files.items(): - fields.update({k: (None, v.read())) + fields.update({k: (k, v.read())}) (body, content_type) = encode_multipart_formdata(fields) # Setup form data. @@ -256,13 +256,16 @@ class Request(object): if isinstance(self.data, basestring): body = self.data else: - body = urlencode(self.data) + body = encode_params(self.data) content_type = 'application/x-www-form-urlencoded' # Setup cookies. elif self.cookies: pass + if (content_type) and (not 'content-type' in self.headers): + self.headers['Content-Type'] = content_type + # Only send the Request if new or forced. if (anyway) or (not self.sent): @@ -296,7 +299,7 @@ class Request(object): r = connection.urlopen( method=self.method, url=url, - body=self.data, + body=body, headers=self.headers, redirect=False, assert_same_host=False,