'Regression test for a failure when redirecting a compressed
request.
This happens when httpcompression middleware is executed before redirect
middleware and attempts to decompress a non-compressed body.
In particular when some website returns a 30x response with header
\'Content-Encoding: gzip\' giving as result the error below:
exceptions.IOError: Not a gzipped file'

def test_3xx_and_invalid_gzipped_body_must_redirect(self):

    req = Request('http://example.com')
    body = '<p>You    are    being    redirected</p>'
    resp = Response(req.url, status=302, body=body, headers={'Content-Length': str(len(body)), 'Content-Type': 'text/html', 'Content-Encoding': 'gzip', 'Location': 'http://example.com/login'})
    ret = self._download(request=req, response=resp)
    self.assertTrue(isinstance(ret, Request), 'Not    redirected:    {0!r}'.format(ret))
    self.assertEqual(to_bytes(ret.url), resp.headers['Location'], 'Not    redirected    to    location    header')
