@@ -594,6 +594,36 @@ public function testFollowRedirectDropPostMethod()
594
594
}
595
595
}
596
596
597
+ /**
598
+ * @dataProvider getTestsForMetaRefresh
599
+ */
600
+ public function testFollowMetaRefresh (string $ content , string $ expectedEndingUrl )
601
+ {
602
+ $ client = new TestClient ();
603
+ $ client ->setNextResponse (new Response ($ content ));
604
+ $ client ->request ('GET ' , 'http://www.example.com/foo/foobar ' );
605
+ $ this ->assertEquals ($ expectedEndingUrl , $ client ->getRequest ()->getUri ());
606
+ }
607
+
608
+ public function getTestsForMetaRefresh ()
609
+ {
610
+ return array (
611
+ array ('<html><head><meta http-equiv="Refresh" content="4" /><meta http-equiv="refresh" content="0; URL=http://www.example.com/redirected"/></head></html> ' , 'http://www.example.com/redirected ' ),
612
+ array ('<html><head><meta http-equiv="refresh" content="0;URL=http://www.example.com/redirected"/></head></html> ' , 'http://www.example.com/redirected ' ),
613
+ array ('<html><head><meta http-equiv="refresh" content="0;URL= \'http://www.example.com/redirected \'"/></head></html> ' , 'http://www.example.com/redirected ' ),
614
+ array ('<html><head><meta http-equiv="refresh" content= \'0;URL="http://www.example.com/redirected" \'/></head></html> ' , 'http://www.example.com/redirected ' ),
615
+ array ('<html><head><meta http-equiv="refresh" content="0; URL = http://www.example.com/redirected"/></head></html> ' , 'http://www.example.com/redirected ' ),
616
+ array ('<html><head><meta http-equiv="refresh" content="0;URL= http://www.example.com/redirected "/></head></html> ' , 'http://www.example.com/redirected ' ),
617
+ array ('<html><head><meta http-equiv="refresh" content="0;url=http://www.example.com/redirected "/></head></html> ' , 'http://www.example.com/redirected ' ),
618
+ array ('<html><head><noscript><meta http-equiv="refresh" content="0;URL=http://www.example.com/redirected"/></noscript></head></head></html> ' , 'http://www.example.com/redirected ' ),
619
+ // Non-zero timeout should not result in a redirect.
620
+ array ('<html><head><meta http-equiv="refresh" content="4; URL=http://www.example.com/redirected"/></head></html> ' , 'http://www.example.com/foo/foobar ' ),
621
+ array ('<html><body></body></html> ' , 'http://www.example.com/foo/foobar ' ),
622
+ // Invalid meta tag placement should not result in a redirect.
623
+ array ('<html><body><meta http-equiv="refresh" content="0;url=http://www.example.com/redirected"/></body></html> ' , 'http://www.example.com/foo/foobar ' ),
624
+ );
625
+ }
626
+
597
627
public function testBack ()
598
628
{
599
629
$ client = new TestClient ();
0 commit comments