diff --git a/aiohttp/multipart.py b/aiohttp/multipart.py index 625c4dc682b..931bb4e2e36 100644 --- a/aiohttp/multipart.py +++ b/aiohttp/multipart.py @@ -756,11 +756,9 @@ def set_content_disposition(self, disptype, **params): raise ValueError('bad content disposition parameter' ' {!r}={!r}'.format(key, val)) qval = quote(val, '') + lparams.append((key, '"%s"' % qval)) if key == 'filename': - lparams.append((key, '"%s"' % qval)) lparams.append(('filename*', "utf-8''" + qval)) - else: - lparams.append((key, "%s" % qval)) sparams = '; '.join('='.join(pair) for pair in lparams) value = '; '.join((value, sparams)) self.headers[CONTENT_DISPOSITION] = value diff --git a/tests/test_multipart.py b/tests/test_multipart.py index 99f842ea10f..f63fbb2d698 100644 --- a/tests/test_multipart.py +++ b/tests/test_multipart.py @@ -633,7 +633,7 @@ def test_autoset_content_disposition(self): def test_set_content_disposition(self): self.part.set_content_disposition('attachment', foo='bar') self.assertEqual( - 'attachment; foo=bar', + 'attachment; foo="bar"', self.part.headers[CONTENT_DISPOSITION]) def test_set_content_disposition_bad_type(self):