@@ -594,6 +594,39 @@ public function testFollowRedirectDropPostMethod()
594
594
}
595
595
}
596
596
597
+ /**
598
+ * @dataProvider getTestsForMetaRefresh
599
+ */
600
+ public function testFollowMetaRefresh (string $ content , string $ expectedEndingUrl , bool $ followMetaRefresh = true )
601
+ {
602
+ $ client = new TestClient ();
603
+ $ client ->followMetaRefresh ($ followMetaRefresh );
604
+ $ client ->setNextResponse (new Response ($ content ));
605
+ $ client ->request ('GET ' , 'http://www.example.com/foo/foobar ' );
606
+ $ this ->assertEquals ($ expectedEndingUrl , $ client ->getRequest ()->getUri ());
607
+ }
608
+
609
+ public function getTestsForMetaRefresh ()
610
+ {
611
+ return array (
612
+ 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 ' ),
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><meta http-equiv="refresh" content="0;url=http://www.example.com/redirected "/></head></html> ' , 'http://www.example.com/redirected ' ),
619
+ 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 ' ),
620
+ // Non-zero timeout should not result in a redirect.
621
+ array ('<html><head><meta http-equiv="refresh" content="4; URL=http://www.example.com/redirected"/></head></html> ' , 'http://www.example.com/foo/foobar ' ),
622
+ array ('<html><body></body></html> ' , 'http://www.example.com/foo/foobar ' ),
623
+ // Invalid meta tag placement should not result in a redirect.
624
+ array ('<html><body><meta http-equiv="refresh" content="0;url=http://www.example.com/redirected"/></body></html> ' , 'http://www.example.com/foo/foobar ' ),
625
+ // Valid meta refresh should not be followed if disabled.
626
+ array ('<html><head><meta http-equiv="refresh" content="0;URL=http://www.example.com/redirected"/></head></html> ' , 'http://www.example.com/foo/foobar ' , false ),
627
+ );
628
+ }
629
+
597
630
public function testBack ()
598
631
{
599
632
$ client = new TestClient ();
0 commit comments