src/Bigcommerce/Api/Connection.php
private function followRedirectPath()
    {
        $this->redirectsFollowed++;

        if ($this->getStatus() == 301 || $this->getStatus() == 302) {
            if ($this->redirectsFollowed < $this->maxRedirects) {
                $location = $this->getHeader('Location');
                $forwardTo = parse_url($location);

                if (isset($forwardTo['scheme']) && isset($forwardTo['host'])) {
                    $url = $location;
                } else {
                    $forwardFrom = parse_url(curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL));
                    $url = $forwardFrom['scheme'] . '://' . $forwardFrom['host'] . $location;
                }

                $this->get($url);
            } else {
                $errorString = "Too many redirects when trying to follow location.";
                throw new NetworkError($errorString, CURLE_TOO_MANY_REDIRECTS);
            }
        } else {
            $this->redirectsFollowed = 0;
        }
    }
private function followRedirectPath()
    {
        $this->redirectsFollowed++;

        if ($this->getStatus() == 301 || $this->getStatus() == 302) {
            if ($this->redirectsFollowed < $this->maxRedirects) {
                $location = $this->getHeader('Location');
                $forwardTo = parse_url($location);

                if (isset($forwardTo['scheme']) && isset($forwardTo['host'])) {
                    $url = $location;
                } else {
                    $forwardFrom = parse_url(curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL));
                    $url = $forwardFrom['scheme'] . '://' . $forwardFrom['host'] . $location;
                }

                $this->get($url);
            } else {
                $errorString = "Too many redirects when trying to follow location.";
                throw new NetworkError($errorString, CURLE_TOO_MANY_REDIRECTS);
            }
        } else {
            $this->redirectsFollowed = 0;
        }
    }
private function followRedirectPath ( ) { $ this -> redirectsFollowed ++ ; if ( $ this -> getStatus ( ) == 301 || $ this -> getStatus ( ) == 302 ) { if ( $ this -> redirectsFollowed < $ this -> maxRedirects ) { $ location = $ this -> getHeader ( 'Location' ) ; $ forwardTo = parse_url ( $ location ) ; if ( isset ( $ forwardTo [ 'scheme' ] ) && isset ( $ forwardTo [ 'host' ] ) ) { $ url = $ location ; } else { $ forwardFrom = parse_url ( curl_getinfo ( $ this -> curl , CURLINFO_EFFECTIVE_URL ) ) ; $ url = $ forwardFrom [ 'scheme' ] . '://' . $ forwardFrom [ 'host' ] . $ location ; } $ this -> get ( $ url ) ; } else { $ errorString = "Too many redirects when trying to follow location." ; throw new NetworkError ( $ errorString , CURLE_TOO_MANY_REDIRECTS ) ; } } else { $ this -> redirectsFollowed = 0 ; } }
Recursively follow redirect until an OK response is received or
the maximum redirects limit is reached.

Only 301 and 302 redirects are handled. Redirects from POST and PUT requests will
be converted into GET requests, as per the HTTP spec.
Recursively follow redirect until an OK response is received or the maximum redirects limit is reached .