def test_compress_streaming_response(self):
     """
     Compression is performed on responses with streaming content.
     """
     r = GZipMiddleware().process_response(self.req, self.stream_resp)
     self.assertEqual(self.decompress(b''.join(r)), b''.join(self.sequence))
     self.assertEqual(r.get('Content-Encoding'), 'gzip')
     self.assertFalse(r.has_header('Content-Length'))
 def test_compress_streaming_response_unicode(self):
     """
     Compression is performed on responses with streaming Unicode content.
     """
     r = CompressionMiddleware().process_response(self.req,
                                                  self.stream_resp_unicode)
     self.assertEqual(
         brotli.decompress(b''.join(r)),
         b''.join(x.encode('utf-8') for x in self.sequence_unicode))
     self.assertEqual(r.get('Content-Encoding'), 'br')
     self.assertFalse(r.has_header('Content-Length'))
     self.assertEqual(r.get('Vary'), 'Accept-Encoding')