@@ -40,6 +40,7 @@ abstract class Client
40
40
protected $ insulated = false ;
41
41
protected $ redirect ;
42
42
protected $ followRedirects = true ;
43
+ protected $ followMetaRefresh = false ;
43
44
44
45
private $ maxRedirects = -1 ;
45
46
private $ redirectCount = 0 ;
@@ -68,6 +69,14 @@ public function followRedirects($followRedirect = true)
68
69
$ this ->followRedirects = (bool ) $ followRedirect ;
69
70
}
70
71
72
+ /**
73
+ * Sets whether to automatically follow meta refresh redirects or not.
74
+ */
75
+ public function followMetaRefresh (bool $ followMetaRefresh = true )
76
+ {
77
+ $ this ->followMetaRefresh = $ followMetaRefresh ;
78
+ }
79
+
71
80
/**
72
81
* Returns whether client automatically follows redirects or not.
73
82
*
@@ -369,9 +378,10 @@ public function request(string $method, string $uri, array $parameters = array()
369
378
370
379
$ this ->crawler = $ this ->createCrawlerFromContent ($ this ->internalRequest ->getUri (), $ this ->internalResponse ->getContent (), $ this ->internalResponse ->getHeader ('Content-Type ' ));
371
380
372
- // Check for meta refresh redirect.
373
- if ($ this ->followRedirects && null !== $ redirect = $ this ->getMetaRefreshUrl ()) {
381
+ // Check for meta refresh redirect
382
+ if ($ this ->followMetaRefresh && null !== $ redirect = $ this ->getMetaRefreshUrl ()) {
374
383
$ this ->redirect = $ redirect ;
384
+ $ this ->redirects [serialize ($ this ->history ->current ())] = true ;
375
385
$ this ->crawler = $ this ->followRedirect ();
376
386
}
377
387
@@ -572,8 +582,6 @@ public function followRedirect()
572
582
}
573
583
574
584
/**
575
- * Get the meta refresh URL if the response has one.
576
- *
577
585
* @see https://dev.w3.org/html5/spec-preview/the-meta-element.html#attr-meta-http-equiv-refresh
578
586
*/
579
587
private function getMetaRefreshUrl (): ?string
0 commit comments