def _assert_resp_len_and_enc_for_gzip(self, uri):
        """
        Test that after querying gzipped content it's remains valid in
        cache and available non-gzipped as well.
        """
        ACCEPT_GZIP_HEADERS = [('Accept-Encoding', 'gzip')]
        content_len = None

        for _ in range(3):
            self.getPage(uri, method='GET', headers=ACCEPT_GZIP_HEADERS)

            if content_len is not None:
                # all requests should get the same length
                self.assertHeader('Content-Length', content_len)
                self.assertHeader('Content-Encoding', 'gzip')

            content_len = dict(self.headers)['Content-Length']

        # check that we can still get non-gzipped version
        self.getPage(uri, method='GET')
        self.assertNoHeader('Content-Encoding')
        # non-gzipped version should have a different content length
        self.assertNoHeaderItemValue('Content-Length', content_len)

        Test that after querying gzipped content it's remains valid in
        cache and available non-gzipped as well.
        
cherrypy/test/test_caching.py