File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -385,6 +385,29 @@ public function send(string $method, string $url)
385
385
// Set the string we want to break our response from
386
386
$ breakString = "\r\n\r\n" ;
387
387
388
+ // Strip out multiple redirect header sections
389
+ if (isset ($ this ->config ['allow_redirects ' ]) && $ this ->config ['allow_redirects ' ] !== false ) {
390
+ while (preg_match ('/^HTTP\/\d(?:\.\d)? 3\d\d/ ' , $ output )) {
391
+ $ breakStringPos = strpos ($ output , $ breakString );
392
+ $ redirectHeaderSection = substr ($ output , 0 , $ breakStringPos );
393
+ $ redirectHeaders = explode ("\n" , $ redirectHeaderSection );
394
+ $ locationHeaderFound = false ;
395
+
396
+ foreach ($ redirectHeaders as $ header ) {
397
+ if (str_starts_with (strtolower ($ header ), 'location: ' )) {
398
+ $ locationHeaderFound = true ;
399
+ break ;
400
+ }
401
+ }
402
+
403
+ if ($ locationHeaderFound ) {
404
+ $ output = substr ($ output , $ breakStringPos + 4 );
405
+ } else {
406
+ break ;
407
+ }
408
+ }
409
+ }
410
+
388
411
while (str_starts_with ($ output , 'HTTP/1.1 100 Continue ' )) {
389
412
$ output = substr ($ output , strpos ($ output , $ breakString ) + 4 );
390
413
}
You can’t perform that action at this time.
0 commit comments