@@ -528,7 +528,7 @@ def test_bytes_data(self):
528
528
529
529
@unittest .mock .patch ('aiohttp.client_reqrep.aiohttp' )
530
530
def test_content_encoding (self , m_http ):
531
- req = ClientRequest ('get' , 'http://python.org/' ,
531
+ req = ClientRequest ('get' , 'http://python.org/' , data = 'foo' ,
532
532
compress = 'deflate' , loop = self .loop )
533
533
resp = req .send (self .transport , self .protocol )
534
534
self .assertEqual (req .headers ['TRANSFER-ENCODING' ], 'chunked' )
@@ -538,10 +538,20 @@ def test_content_encoding(self, m_http):
538
538
self .loop .run_until_complete (req .close ())
539
539
resp .close ()
540
540
541
+ @unittest .mock .patch ('aiohttp.client_reqrep.aiohttp' )
542
+ def test_content_encoding_dont_set_headers_if_no_body (self , m_http ):
543
+ req = ClientRequest ('get' , 'http://python.org/' ,
544
+ compress = 'deflate' , loop = self .loop )
545
+ resp = req .send (self .transport , self .protocol )
546
+ self .assertNotIn ('TRANSFER-ENCODING' , req .headers )
547
+ self .assertNotIn ('CONTENT-ENCODING' , req .headers )
548
+ self .loop .run_until_complete (req .close ())
549
+ resp .close ()
550
+
541
551
@unittest .mock .patch ('aiohttp.client_reqrep.aiohttp' )
542
552
def test_content_encoding_header (self , m_http ):
543
553
req = ClientRequest (
544
- 'get' , 'http://python.org/' ,
554
+ 'get' , 'http://python.org/' , data = 'foo' ,
545
555
headers = {'Content-Encoding' : 'deflate' }, loop = self .loop )
546
556
resp = req .send (self .transport , self .protocol )
547
557
self .assertEqual (req .headers ['TRANSFER-ENCODING' ], 'chunked' )
0 commit comments