'Imagine a single HTTPS connection with three requests:
1. First request should pass through unmodified
2. Second request will be redirected to a different host by an inline script
3. Third request should pass through unmodified
This test verifies that the original destination is restored for the third request.'

def test_redirect(self):

    self.proxy.tmaster.addons.add(ARedirectRequest(self.server2.port))
    p = self.pathoc()
    with p.connect():
        self.server.clear_log()
        self.server2.clear_log()
        r1 = p.request("get:'/p/200'")
        assert (r1.status_code == 200)
        assert self.server.last_log()
        assert (not self.server2.expect_log(1, 0.5))
        self.server.clear_log()
        self.server2.clear_log()
        r2 = p.request("get:'/p/201'")
        assert (r2.status_code == 201)
        assert (not self.server.expect_log(1, 0.5))
        assert self.server2.last_log()
        self.server.clear_log()
        self.server2.clear_log()
        r3 = p.request("get:'/p/202'")
        assert (r3.status_code == 202)
        assert self.server.last_log()
        assert (not self.server2.expect_log(1, 0.5))
        assert (r1.content == r2.content == r3.content)
